Skip to content
Snippets Groups Projects
Select Git revision
  • 65d472fb007dd73ef28f70078f43f86bb6cc67d0
  • master default
  • kernelci-local
  • kernelci-stable
  • beaglebone-black-next-20190304-debug
  • next-20190301-beaglebone-black-debug
  • kernelci/slash-in-branch-name
  • next-20180215-fixup
  • kernelci-ref
  • linux-4.20-mali-bifrost-r16p0
  • kernelci-staging
  • kernelci-bisect
  • next-20181206-jeston-tk1-nouveau-fix
  • 4.20-rc1-beagle-xm-smp-preempt-bisect
  • bisect-exp
  • linux-4.4.152-bisect-atom-x5
  • linux-3.18.y-exynos-nfsroot
  • linux-4.14-mali-rk3288
  • linux-4.4.110-odroidxu3-fixup-mfc-regions
  • linux-4.15-rc4-drm-tegra124-fixup
  • bisect-3199-peach-pi
  • kernelci-local-snapshot-033
  • v4.20.16
  • kernelci-local-snapshot-032
  • next-20190304
  • next-20190301
  • v4.20.12
  • kernelci-local-snapshot-030
  • kernelci-local-snapshot-029
  • kernelci-local-snapshot-028
  • kernelci-local-snapshot-027
  • kernelci-local-snapshot-026
  • kernelci-local-snapshot-025
  • kernelci-local-snapshot-024
  • kernelci-local-snapshot-023
  • kernelci-local-snapshot-022
  • kernelci-local-snapshot-021
  • v4.20.5
  • kernelci-local-snapshot-020
  • kernelci-local-snapshot-019
  • kernelci-local-snapshot-018
41 results

parse_ldabs.c

Blame
  • Forked from Guillaume Tucker / linux
    Source project has a limited visibility.
    parse_ldabs.c 1.15 KiB
    /* Copyright (c) 2016 Facebook
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of version 2 of the GNU General Public
     * License as published by the Free Software Foundation.
     */
    #include <linux/ip.h>
    #include <linux/ipv6.h>
    #include <linux/in.h>
    #include <linux/tcp.h>
    #include <linux/udp.h>
    #include <uapi/linux/bpf.h>
    #include "bpf_helpers.h"
    
    #define DEFAULT_PKTGEN_UDP_PORT	9
    #define IP_MF			0x2000
    #define IP_OFFSET		0x1FFF
    
    static inline int ip_is_fragment(struct __sk_buff *ctx, __u64 nhoff)
    {
    	return load_half(ctx, nhoff + offsetof(struct iphdr, frag_off))
    		& (IP_MF | IP_OFFSET);
    }
    
    SEC("ldabs")
    int handle_ingress(struct __sk_buff *skb)
    {
    	__u64 troff = ETH_HLEN + sizeof(struct iphdr);
    
    	if (load_half(skb, offsetof(struct ethhdr, h_proto)) != ETH_P_IP)
    		return 0;
    	if (load_byte(skb, ETH_HLEN + offsetof(struct iphdr, protocol)) != IPPROTO_UDP ||
    	    load_byte(skb, ETH_HLEN) != 0x45)
    		return 0;
    	if (ip_is_fragment(skb, ETH_HLEN))
    		return 0;
    	if (load_half(skb, troff + offsetof(struct udphdr, dest)) == DEFAULT_PKTGEN_UDP_PORT)
    		return TC_ACT_SHOT;
    	return 0;
    }
    char _license[] SEC("license") = "GPL";