Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

netfilter: flowtable: inline pppoe encapsulation in xmit path

Push the pppoe header from the flowtable xmit path, inlining is faster
than the original xmit path because it can avoid some locking.

This is based on a patch originally written by wenxu.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>

+44 -7
+42
net/netfilter/nf_flow_table_ip.c
··· 413 413 return 1; 414 414 } 415 415 416 + static int nf_flow_pppoe_push(struct sk_buff *skb, u16 id) 417 + { 418 + int data_len = skb->len + sizeof(__be16); 419 + struct ppp_hdr { 420 + struct pppoe_hdr hdr; 421 + __be16 proto; 422 + } *ph; 423 + __be16 proto; 424 + 425 + if (skb_cow_head(skb, PPPOE_SES_HLEN)) 426 + return -1; 427 + 428 + switch (skb->protocol) { 429 + case htons(ETH_P_IP): 430 + proto = htons(PPP_IP); 431 + break; 432 + case htons(ETH_P_IPV6): 433 + proto = htons(PPP_IPV6); 434 + break; 435 + default: 436 + return -1; 437 + } 438 + 439 + __skb_push(skb, PPPOE_SES_HLEN); 440 + skb_reset_network_header(skb); 441 + 442 + ph = (struct ppp_hdr *)(skb->data); 443 + ph->hdr.ver = 1; 444 + ph->hdr.type = 1; 445 + ph->hdr.code = 0; 446 + ph->hdr.sid = htons(id); 447 + ph->hdr.length = htons(data_len); 448 + ph->proto = proto; 449 + skb->protocol = htons(ETH_P_PPP_SES); 450 + 451 + return 0; 452 + } 453 + 416 454 static int nf_flow_encap_push(struct sk_buff *skb, 417 455 struct flow_offload_tuple *tuple) 418 456 { ··· 462 424 case htons(ETH_P_8021AD): 463 425 if (skb_vlan_push(skb, tuple->encap[i].proto, 464 426 tuple->encap[i].id) < 0) 427 + return -1; 428 + break; 429 + case htons(ETH_P_PPP_SES): 430 + if (nf_flow_pppoe_push(skb, tuple->encap[i].id) < 0) 465 431 return -1; 466 432 break; 467 433 }
+2 -7
net/netfilter/nf_flow_table_path.c
··· 122 122 info->encap[info->num_encaps].id = path->encap.id; 123 123 info->encap[info->num_encaps].proto = path->encap.proto; 124 124 info->num_encaps++; 125 - if (path->type == DEV_PATH_PPPOE) { 126 - if (!info->outdev) 127 - info->outdev = path->dev; 125 + if (path->type == DEV_PATH_PPPOE) 128 126 memcpy(info->h_dest, path->encap.h_dest, ETH_ALEN); 129 - } 130 127 break; 131 128 case DEV_PATH_BRIDGE: 132 129 if (is_zero_ether_addr(info->h_source)) ··· 158 161 break; 159 162 } 160 163 } 161 - if (!info->outdev) 162 - info->outdev = info->indev; 163 - 164 + info->outdev = info->indev; 164 165 info->hw_outdev = info->indev; 165 166 166 167 if (nf_flowtable_hw_offload(flowtable) &&