tunnel: eliminate recursion field

It seems recursion field from "struct ip_tunnel" is not anymore needed.
recursion prevention is done at the upper level (in dev_queue_xmit()),
since we use HARD_TX_LOCK protection for tunnels.

This avoids a cache line ping pong on "struct ip_tunnel" : This structure
should be now mostly read on xmit and receive paths.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
a43912ab edf42a27

+1 -36
-1
include/net/ipip.h
··· 12 12 struct ip_tunnel *next; 13 13 struct net_device *dev; 14 14 15 - int recursion; /* Depth of hard_start_xmit recursion */ 16 15 int err_count; /* Number of arrived ICMP errors */ 17 16 unsigned long err_time; /* Time when the last ICMP error arrived */ 18 17
+1 -12
net/ipv4/ip_gre.c
··· 66 66 solution, but it supposes maintaing new variable in ALL 67 67 skb, even if no tunneling is used. 68 68 69 - Current solution: t->recursion lock breaks dead loops. It looks 70 - like dev->tbusy flag, but I preferred new variable, because 71 - the semantics is different. One day, when hard_start_xmit 72 - will be multithreaded we will have to use skb->encapsulation. 69 + Current solution: HARD_TX_LOCK lock breaks dead loops. 73 70 74 71 75 72 ··· 675 678 __be32 dst; 676 679 int mtu; 677 680 678 - if (tunnel->recursion++) { 679 - stats->collisions++; 680 - goto tx_error; 681 - } 682 - 683 681 if (dev->type == ARPHRD_ETHER) 684 682 IPCB(skb)->flags = 0; 685 683 ··· 812 820 ip_rt_put(rt); 813 821 stats->tx_dropped++; 814 822 dev_kfree_skb(skb); 815 - tunnel->recursion--; 816 823 return NETDEV_TX_OK; 817 824 } 818 825 if (skb->sk) ··· 879 888 nf_reset(skb); 880 889 881 890 IPTUNNEL_XMIT(); 882 - tunnel->recursion--; 883 891 return NETDEV_TX_OK; 884 892 885 893 tx_error_icmp: ··· 887 897 tx_error: 888 898 stats->tx_errors++; 889 899 dev_kfree_skb(skb); 890 - tunnel->recursion--; 891 900 return NETDEV_TX_OK; 892 901 } 893 902
-8
net/ipv4/ipip.c
··· 402 402 __be32 dst = tiph->daddr; 403 403 int mtu; 404 404 405 - if (tunnel->recursion++) { 406 - stats->collisions++; 407 - goto tx_error; 408 - } 409 - 410 405 if (skb->protocol != htons(ETH_P_IP)) 411 406 goto tx_error; 412 407 ··· 480 485 ip_rt_put(rt); 481 486 stats->tx_dropped++; 482 487 dev_kfree_skb(skb); 483 - tunnel->recursion--; 484 488 return NETDEV_TX_OK; 485 489 } 486 490 if (skb->sk) ··· 517 523 nf_reset(skb); 518 524 519 525 IPTUNNEL_XMIT(); 520 - tunnel->recursion--; 521 526 return NETDEV_TX_OK; 522 527 523 528 tx_error_icmp: ··· 524 531 tx_error: 525 532 stats->tx_errors++; 526 533 dev_kfree_skb(skb); 527 - tunnel->recursion--; 528 534 return NETDEV_TX_OK; 529 535 } 530 536
-7
net/ipv6/ip6_tunnel.c
··· 1043 1043 struct net_device_stats *stats = &t->dev->stats; 1044 1044 int ret; 1045 1045 1046 - if (t->recursion++) { 1047 - stats->collisions++; 1048 - goto tx_err; 1049 - } 1050 - 1051 1046 switch (skb->protocol) { 1052 1047 case htons(ETH_P_IP): 1053 1048 ret = ip4ip6_tnl_xmit(skb, dev); ··· 1057 1062 if (ret < 0) 1058 1063 goto tx_err; 1059 1064 1060 - t->recursion--; 1061 1065 return NETDEV_TX_OK; 1062 1066 1063 1067 tx_err: 1064 1068 stats->tx_errors++; 1065 1069 stats->tx_dropped++; 1066 1070 kfree_skb(skb); 1067 - t->recursion--; 1068 1071 return NETDEV_TX_OK; 1069 1072 } 1070 1073
-8
net/ipv6/sit.c
··· 626 626 struct in6_addr *addr6; 627 627 int addr_type; 628 628 629 - if (tunnel->recursion++) { 630 - stats->collisions++; 631 - goto tx_error; 632 - } 633 - 634 629 if (skb->protocol != htons(ETH_P_IPV6)) 635 630 goto tx_error; 636 631 ··· 748 753 ip_rt_put(rt); 749 754 stats->tx_dropped++; 750 755 dev_kfree_skb(skb); 751 - tunnel->recursion--; 752 756 return NETDEV_TX_OK; 753 757 } 754 758 if (skb->sk) ··· 788 794 nf_reset(skb); 789 795 790 796 IPTUNNEL_XMIT(); 791 - tunnel->recursion--; 792 797 return NETDEV_TX_OK; 793 798 794 799 tx_error_icmp: ··· 795 802 tx_error: 796 803 stats->tx_errors++; 797 804 dev_kfree_skb(skb); 798 - tunnel->recursion--; 799 805 return NETDEV_TX_OK; 800 806 } 801 807