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/ipv4/ip_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/ipv4/ip_output.c')
-rw-r--r-- | net/ipv4/ip_output.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index b99ca4e154b9..0f3185a662c3 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -113,19 +113,6 @@ int ip_local_out(struct sk_buff *skb) | |||
113 | } | 113 | } |
114 | EXPORT_SYMBOL_GPL(ip_local_out); | 114 | EXPORT_SYMBOL_GPL(ip_local_out); |
115 | 115 | ||
116 | /* dev_loopback_xmit for use with netfilter. */ | ||
117 | static int ip_dev_loopback_xmit(struct sk_buff *newskb) | ||
118 | { | ||
119 | skb_reset_mac_header(newskb); | ||
120 | __skb_pull(newskb, skb_network_offset(newskb)); | ||
121 | newskb->pkt_type = PACKET_LOOPBACK; | ||
122 | newskb->ip_summed = CHECKSUM_UNNECESSARY; | ||
123 | WARN_ON(!skb_dst(newskb)); | ||
124 | skb_dst_force(newskb); | ||
125 | netif_rx_ni(newskb); | ||
126 | return 0; | ||
127 | } | ||
128 | |||
129 | static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst) | 116 | static inline int ip_select_ttl(struct inet_sock *inet, struct dst_entry *dst) |
130 | { | 117 | { |
131 | int ttl = inet->uc_ttl; | 118 | int ttl = inet->uc_ttl; |
@@ -281,7 +268,7 @@ int ip_mc_output(struct sk_buff *skb) | |||
281 | if (newskb) | 268 | if (newskb) |
282 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, | 269 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, |
283 | newskb, NULL, newskb->dev, | 270 | newskb, NULL, newskb->dev, |
284 | ip_dev_loopback_xmit); | 271 | dev_loopback_xmit); |
285 | } | 272 | } |
286 | 273 | ||
287 | /* Multicasts with ttl 0 must not go beyond the host */ | 274 | /* Multicasts with ttl 0 must not go beyond the host */ |
@@ -296,7 +283,7 @@ int ip_mc_output(struct sk_buff *skb) | |||
296 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); | 283 | struct sk_buff *newskb = skb_clone(skb, GFP_ATOMIC); |
297 | if (newskb) | 284 | if (newskb) |
298 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, newskb, | 285 | NF_HOOK(NFPROTO_IPV4, NF_INET_POST_ROUTING, newskb, |
299 | NULL, newskb->dev, ip_dev_loopback_xmit); | 286 | NULL, newskb->dev, dev_loopback_xmit); |
300 | } | 287 | } |
301 | 288 | ||
302 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, NULL, | 289 | return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING, skb, NULL, |