Patchwork [1/5] net: Create and use new helper, neigh_output().

login
register
mail settings
Submitter David Miller
Date July 17, 2011, 7:30 p.m.
Message ID <20110717.123007.1736899942069308447.davem@davemloft.net>
Download mbox | patch
Permalink /patch/105087/
State Accepted
Delegated to: David Miller
Headers show

Comments

David Miller - July 17, 2011, 7:30 p.m.
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/net/neighbour.h |    9 +++++++++
 net/ipv4/ip_output.c    |   10 +++-------
 net/ipv6/ip6_output.c   |   10 +++-------
 3 files changed, 15 insertions(+), 14 deletions(-)

Patch

diff --git a/include/net/neighbour.h b/include/net/neighbour.h
index bd8f9f0..337da24 100644
--- a/include/net/neighbour.h
+++ b/include/net/neighbour.h
@@ -344,6 +344,15 @@  static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb)
 	return hh->hh_output(skb);
 }
 
+static inline int neigh_output(struct neighbour *n, struct sk_buff *skb)
+{
+	struct hh_cache *hh = &n->hh;
+	if (hh->hh_len)
+		return neigh_hh_output(hh, skb);
+	else
+		return n->output(skb);
+}
+
 static inline struct neighbour *
 __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat)
 {
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 1ac674a..db296a9 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -205,13 +205,9 @@  static inline int ip_finish_output2(struct sk_buff *skb)
 	}
 
 	neigh = dst->neighbour;
-	if (neigh) {
-		struct hh_cache *hh = &neigh->hh;
-		if (hh->hh_len)
-			return neigh_hh_output(hh, skb);
-		else
-			return neigh->output(skb);
-	}
+	if (neigh)
+		return neigh_output(neigh, skb);
+
 	if (net_ratelimit())
 		printk(KERN_DEBUG "ip_finish_output2: No header cache and no neighbour!\n");
 	kfree_skb(skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 36362e9..eb50bb0 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -136,13 +136,9 @@  static int ip6_finish_output2(struct sk_buff *skb)
 	}
 
 	neigh = dst->neighbour;
-	if (neigh) {
-		struct hh_cache *hh = &neigh->hh;
-		if (hh->hh_len)
-			return neigh_hh_output(hh, skb);
-		else
-			return neigh->output(skb);
-	}
+	if (neigh)
+		return neigh_output(neigh, skb);
+
 	IP6_INC_STATS_BH(dev_net(dst->dev),
 			 ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES);
 	kfree_skb(skb);