diff options
author | Michel Machado <michel@digirati.com.br> | 2012-06-12 06:16:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-12 21:51:09 -0400 |
commit | 95603e2293de556de7e82221649bfd7fd98b64a3 (patch) | |
tree | d90e7570b072f62ee4fefa619b93ec771bfd9f95 /net/ipv6/ip6_output.c | |
parent | de063b7040dcd9fbc9a1847fa44f0af13e19d6de (diff) |
net-next: add dev_loopback_xmit() to avoid duplicate code
Add dev_loopback_xmit() in order to deduplicate functions
ip_dev_loopback_xmit() (in net/ipv4/ip_output.c) and
ip6_dev_loopback_xmit() (in net/ipv6/ip6_output.c).
I was about to reinvent the wheel when I noticed that
ip_dev_loopback_xmit() and ip6_dev_loopback_xmit() do exactly what I
need and are not IP-only functions, but they were not available to reuse
elsewhere.
ip6_dev_loopback_xmit() does not have line "skb_dst_force(skb);", but I
understand that this is harmless, and should be in dev_loopback_xmit().
Signed-off-by: Michel Machado <michel@digirati.com.br>
CC: "David S. Miller" <davem@davemloft.net>
CC: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
CC: James Morris <jmorris@namei.org>
CC: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
CC: Patrick McHardy <kaber@trash.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jpirko@redhat.com>
CC: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
CC: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/ip6_output.c')
-rw-r--r-- | net/ipv6/ip6_output.c | 15 |
1 files changed, 1 insertions, 14 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 62fcf3e48aca..ee1bb450bfe4 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -83,19 +83,6 @@ int ip6_local_out(struct sk_buff *skb) | |||
83 | } | 83 | } |
84 | EXPORT_SYMBOL_GPL(ip6_local_out); | 84 | EXPORT_SYMBOL_GPL(ip6_local_out); |
85 | 85 | ||
86 | /* dev_loopback_xmit for use with netfilter. */ | ||
87 | static int ip6_dev_loopback_xmit(struct sk_buff *newskb) | ||
88 | { | ||
89 | skb_reset_mac_header(newskb); | ||
90 | __skb_pull(newskb, skb_network_offset(newskb)); | ||
91 | newskb->pkt_type = PACKET_LOOPBACK; | ||
92 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | ||
93 | WARN_ON(!skb_dst(newskb)); | ||
94 | |||
95 | netif_rx_ni(newskb); | ||
96 | return 0; | ||
97 | } | ||
98 | |||
99 | static int ip6_finish_output2(struct sk_buff *skb) | 86 | static int ip6_finish_output2(struct sk_buff *skb) |
100 | { | 87 | { |
101 | struct dst_entry *dst = skb_dst(skb); | 88 | struct dst_entry *dst = skb_dst(skb); |
@@ -121,7 +108,7 @@ static int ip6_finish_output2(struct sk_buff *skb) | |||
121 | if (newskb) | 108 | if (newskb) |
122 | NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, | 109 | NF_HOOK(NFPROTO_IPV6, NF_INET_POST_ROUTING, |
123 | newskb, NULL, newskb->dev, | 110 | newskb, NULL, newskb->dev, |
124 | ip6_dev_loopback_xmit); | 111 | dev_loopback_xmit); |
125 | 112 | ||
126 | if (ipv6_hdr(skb)->hop_limit == 0) { | 113 | if (ipv6_hdr(skb)->hop_limit == 0) { |
127 | IP6_INC_STATS(dev_net(dev), idev, | 114 | IP6_INC_STATS(dev_net(dev), idev, |