File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77// The parsing helper functions from the packet01 lesson have moved here
88#include "../common/parsing_helpers.h"
99
10-
1110/* Pops the outermost VLAN tag off the packet. Returns the popped VLAN ID on
1211 * success or -1 on failure.
1312 */
@@ -92,6 +91,12 @@ int xdp_parser_func(struct xdp_md *ctx)
9291 void * data_end = (void * )(long )ctx -> data_end ;
9392 void * data = (void * )(long )ctx -> data ;
9493
94+ /* Default action XDP_PASS, imply everything we couldn't parse, or that
95+ * we don't want to deal with, we just pass up the stack and let the
96+ * kernel deal with it.
97+ */
98+ __u32 action = XDP_PASS ; /* Default action */
99+
95100 /* These keep track of the next header type and iterator pointer */
96101 struct hdr_cursor nh ;
97102 int nh_type ;
@@ -118,7 +123,7 @@ int xdp_parser_func(struct xdp_md *ctx)
118123 goto out ;
119124
120125 if (bpf_ntohs (icmp6h -> icmp6_sequence ) % 2 == 0 )
121- return XDP_DROP ;
126+ action = XDP_DROP ;
122127
123128 } else if (nh_type == ETH_P_IP ) {
124129 struct iphdr * iph ;
@@ -133,13 +138,10 @@ int xdp_parser_func(struct xdp_md *ctx)
133138 goto out ;
134139
135140 if (bpf_ntohs (icmph -> un .echo .sequence ) % 2 == 0 )
136- return XDP_DROP ;
141+ action = XDP_DROP ;
137142 }
138143out :
139- /* Everything we couldn't parse, or that we don't want to deal with, we
140- * just pass up the stack and let the kernel deal with it.
141- */
142- return XDP_PASS ;
144+ return action ;
143145}
144146
145147char _license [] SEC ("license" ) = "GPL" ;
You can’t perform that action at this time.
0 commit comments