@@ -198,74 +198,6 @@ __attribute__((__always_inline__)) static inline void connection_table_lookup(
198
198
return ;
199
199
}
200
200
201
- __attribute__((__always_inline__ )) static inline int process_l3_headers (
202
- struct packet_description * pckt ,
203
- __u8 * protocol ,
204
- __u64 nh_off , // network header offset (IPv4/IPv6)
205
- __u64 * th_off , // transport header offset (TCP/UDP/...)
206
- __u16 * pkt_bytes ,
207
- void * data ,
208
- void * data_end ,
209
- bool is_ipv6 ) {
210
- __u64 iph_len ;
211
- struct iphdr * iph ;
212
- struct ipv6hdr * ip6h ;
213
- if (is_ipv6 ) {
214
- ip6h = data + nh_off ;
215
- if (ip6h + 1 > data_end ) {
216
- return XDP_DROP ;
217
- }
218
-
219
- iph_len = sizeof (struct ipv6hdr );
220
- * protocol = ip6h -> nexthdr ;
221
- pckt -> flow .proto = * protocol ;
222
-
223
- // copy tos from the packet
224
- pckt -> tos = (ip6h -> priority << 4 ) & 0xF0 ;
225
- pckt -> tos = pckt -> tos | ((ip6h -> flow_lbl [0 ] >> 4 ) & 0x0F );
226
-
227
- * pkt_bytes = bpf_ntohs (ip6h -> payload_len );
228
- * th_off += nh_off + iph_len ;
229
- if (* protocol == IPPROTO_FRAGMENT ) {
230
- // we drop fragmented packets
231
- return XDP_DROP ;
232
- } else if (* protocol == IPPROTO_ICMPV6 ) {
233
- return FURTHER_PROCESSING ;
234
- } else {
235
- memcpy (pckt -> flow .srcv6 , ip6h -> saddr .s6_addr32 , 16 );
236
- memcpy (pckt -> flow .dstv6 , ip6h -> daddr .s6_addr32 , 16 );
237
- }
238
- } else {
239
- iph = data + nh_off ;
240
- if (iph + 1 > data_end ) {
241
- return XDP_DROP ;
242
- }
243
- // ihl contains len of ipv4 header in 32bit words
244
- if (iph -> ihl != 5 ) {
245
- // if len of ipv4 hdr is not equal to 20bytes that means that header
246
- // contains ip options, and we dont support em
247
- return XDP_DROP ;
248
- }
249
- pckt -> tos = iph -> tos ;
250
- * protocol = iph -> protocol ;
251
- pckt -> flow .proto = * protocol ;
252
- * pkt_bytes = bpf_ntohs (iph -> tot_len );
253
- * th_off += nh_off + IPV4_HDR_LEN_NO_OPT ;
254
-
255
- if (iph -> frag_off & PCKT_FRAGMENTED ) {
256
- // we drop fragmented packets.
257
- return XDP_DROP ;
258
- }
259
- if (* protocol == IPPROTO_ICMP ) {
260
- return FURTHER_PROCESSING ;
261
- } else {
262
- pckt -> flow .src = iph -> saddr ;
263
- pckt -> flow .dst = iph -> daddr ;
264
- }
265
- }
266
- return FURTHER_PROCESSING ;
267
- }
268
-
269
201
#ifdef INLINE_DECAP_GENERIC
270
202
__attribute__((__always_inline__ )) static inline int
271
203
check_decap_dst (struct packet_description * pckt , bool is_ipv6 , bool * pass ) {
@@ -437,7 +369,7 @@ incr_decap_vip_stats(void* data, __u64 nh_off, void* data_end, bool is_ipv6) {
437
369
__u8 inner_protocol ;
438
370
__u16 inner_pkt_bytes ;
439
371
__u64 th_off = 0 ;
440
- if (process_l3_headers (
372
+ if (parse_l3_headers (
441
373
& inner_pckt ,
442
374
& inner_protocol ,
443
375
nh_off ,
@@ -711,7 +643,7 @@ process_packet(struct xdp_md* xdp, __u64 nh_off, bool is_ipv6) {
711
643
__u32 mac_addr_pos = 0 ;
712
644
__u16 pkt_bytes ;
713
645
__u64 th_off = 0 ;
714
- action = process_l3_headers (
646
+ action = parse_l3_headers (
715
647
& pckt , & protocol , nh_off , & th_off , & pkt_bytes , data , data_end , is_ipv6 );
716
648
if (action >= 0 ) {
717
649
return action ;
0 commit comments