0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <uapi/linux/bpf.h>
0015 #include <uapi/linux/if_ether.h>
0016 #include <uapi/linux/if_packet.h>
0017 #include <uapi/linux/ip.h>
0018 #include <linux/socket.h>
0019 #include <bpf/bpf_helpers.h>
0020 #include <bpf/bpf_endian.h>
0021
0022 #define DEBUG 1
0023
0024 SEC("sockops")
0025 int bpf_rwnd(struct bpf_sock_ops *skops)
0026 {
0027 int rv = -1;
0028 int op;
0029
0030
0031
0032
0033 if (bpf_ntohl(skops->remote_port) !=
0034 55601 && skops->local_port != 55601) {
0035 skops->reply = -1;
0036 return 1;
0037 }
0038
0039 op = (int) skops->op;
0040
0041 #ifdef DEBUG
0042 bpf_printk("BPF command: %d\n", op);
0043 #endif
0044
0045
0046 if (op == BPF_SOCK_OPS_RWND_INIT &&
0047 skops->family == AF_INET6) {
0048
0049
0050
0051
0052
0053 if (skops->local_ip6[0] != skops->remote_ip6[0] ||
0054 (bpf_ntohl(skops->local_ip6[1]) & 0xfffff000) !=
0055 (bpf_ntohl(skops->remote_ip6[1]) & 0xfffff000))
0056 rv = 40;
0057 }
0058 #ifdef DEBUG
0059 bpf_printk("Returning %d\n", rv);
0060 #endif
0061 skops->reply = rv;
0062 return 1;
0063 }
0064 char _license[] SEC("license") = "GPL";