aboutsummaryrefslogtreecommitdiffstats
path: root/net/core/dev.c
diff options
context:
space:
mode:
authorMichel Machado <michel@digirati.com.br>2012-06-12 06:16:35 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-12 21:51:09 -0400
commit95603e2293de556de7e82221649bfd7fd98b64a3 (patch)
treed90e7570b072f62ee4fefa619b93ec771bfd9f95 /net/core/dev.c
parentde063b7040dcd9fbc9a1847fa44f0af13e19d6de (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/core/dev.c')
-rw-r--r--net/core/dev.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c
index cd0981977f5c..c6e29ea65bd9 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2476,6 +2476,23 @@ static DEFINE_PER_CPU(int, xmit_recursion);
2476#define RECURSION_LIMIT 10 2476#define RECURSION_LIMIT 10
2477 2477
2478/** 2478/**
2479 * dev_loopback_xmit - loop back @skb
2480 * @skb: buffer to transmit
2481 */
2482int dev_loopback_xmit(struct sk_buff *skb)
2483{
2484 skb_reset_mac_header(skb);
2485 __skb_pull(skb, skb_network_offset(skb));
2486 skb->pkt_type = PACKET_LOOPBACK;
2487 skb->ip_summed = CHECKSUM_UNNECESSARY;
2488 WARN_ON(!skb_dst(skb));
2489 skb_dst_force(skb);
2490 netif_rx_ni(skb);
2491 return 0;
2492}
2493EXPORT_SYMBOL(dev_loopback_xmit);
2494
2495/**
2479 * dev_queue_xmit - transmit a buffer 2496 * dev_queue_xmit - transmit a buffer
2480 * @skb: buffer to transmit 2497 * @skb: buffer to transmit
2481 * 2498 *