X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=xdp.c;h=75a44ff2a16d0a22a3cd462107feeec7dd3997c1;hb=ac33c8518d541b228fc24efcb89858abca0fc75f;hp=8f73d809ce75d6f7f886a07f0094e254d19da1a7;hpb=c9cc1ccad026928d22628ab8f5f82b3520b85a61;p=flowspec-xdp diff --git a/xdp.c b/xdp.c index 8f73d80..75a44ff 100644 --- a/xdp.c +++ b/xdp.c @@ -264,8 +264,7 @@ int xdp_drop_prog(struct xdp_md *ctx) const void *l4hdr = NULL; const struct tcphdr *tcp = NULL; - uint8_t ports_valid = 0; - uint16_t sport, dport; // Host Endian! Only valid with tcp || udp + int32_t sport = -1, dport = -1; // Host Endian! Only valid with tcp || udp #ifdef NEED_V4_PARSE if (eth_proto == BE16(ETH_P_IP)) { @@ -287,13 +286,11 @@ int xdp_drop_prog(struct xdp_md *ctx) tcp = (struct tcphdr*) l4hdr; sport = BE16(tcp->source); dport = BE16(tcp->dest); - ports_valid = 1; } else if (ip->protocol == IP_PROTO_UDP) { CHECK_LEN(l4hdr, udphdr); const struct udphdr *udp = (struct udphdr*) l4hdr; sport = BE16(udp->source); dport = BE16(udp->dest); - ports_valid = 1; } else if (ip->protocol == IP_PROTO_ICMP) { CHECK_LEN(l4hdr, icmphdr); icmp = (struct icmphdr*) l4hdr; @@ -334,13 +331,11 @@ int xdp_drop_prog(struct xdp_md *ctx) tcp = (struct tcphdr*) l4hdr; sport = BE16(tcp->source); dport = BE16(tcp->dest); - ports_valid = 1; } else if (v6nexthdr == IP_PROTO_UDP) { CHECK_LEN(l4hdr, udphdr); const struct udphdr *udp = (struct udphdr*) l4hdr; sport = BE16(udp->source); dport = BE16(udp->dest); - ports_valid = 1; } else if (v6nexthdr == IP6_PROTO_ICMPV6) { CHECK_LEN(l4hdr, icmp6hdr); icmpv6 = (struct icmp6hdr*) l4hdr;