aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-11-14 00:34:06 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 17:53:37 -0500
commit352e512c32b634768303a43768245a0363cebbe7 (patch)
tree97509ac130ecbe2084808271ccc459918a9d5fc1
parentb4ce92775c2e7ff9cf79cca4e0a19c8c5fd6287b (diff)
[NET]: Eliminate duplicate copies of dst_discard
We have a number of copies of dst_discard scattered around the place which all do the same thing, namely free a packet on the input or output paths. This patch deletes all of them except dst_discard and points all the users to it. The only non-trivial bit is decnet where it returns an error. However, conceptually this is identical to the blackhole functions used in IPv4 and IPv6 which do not return errors. So they should either all return errors or all return zero. For now I've stuck with the majority and picked zero as the return value. It doesn't really matter in practice since few if any driver would react differently depending on a zero return value or NET_RX_DROP. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/dst.h1
-rw-r--r--net/core/dst.c3
-rw-r--r--net/decnet/dn_route.c13
-rw-r--r--net/ipv4/route.c11
-rw-r--r--net/ipv6/exthdrs.c13
-rw-r--r--net/ipv6/route.c21
6 files changed, 13 insertions, 49 deletions
diff --git a/include/net/dst.h b/include/net/dst.h
index 69888f1502b1..7a0b1bde8e28 100644
--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -179,6 +179,7 @@ static inline struct dst_entry *dst_pop(struct dst_entry *dst)
179 return child; 179 return child;
180} 180}
181 181
182extern int dst_discard(struct sk_buff *skb);
182extern void * dst_alloc(struct dst_ops * ops); 183extern void * dst_alloc(struct dst_ops * ops);
183extern void __dst_free(struct dst_entry * dst); 184extern void __dst_free(struct dst_entry * dst);
184extern struct dst_entry *dst_destroy(struct dst_entry * dst); 185extern struct dst_entry *dst_destroy(struct dst_entry * dst);
diff --git a/net/core/dst.c b/net/core/dst.c
index 03daead3592a..f538061f4b93 100644
--- a/net/core/dst.c
+++ b/net/core/dst.c
@@ -153,11 +153,12 @@ loop:
153#endif 153#endif
154} 154}
155 155
156static int dst_discard(struct sk_buff *skb) 156int dst_discard(struct sk_buff *skb)
157{ 157{
158 kfree_skb(skb); 158 kfree_skb(skb);
159 return 0; 159 return 0;
160} 160}
161EXPORT_SYMBOL(dst_discard);
161 162
162void * dst_alloc(struct dst_ops * ops) 163void * dst_alloc(struct dst_ops * ops)
163{ 164{
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 23aa3556e56f..2a5bb0714c7e 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -765,17 +765,6 @@ drop:
765} 765}
766 766
767/* 767/*
768 * Drop packet. This is used for endnodes and for
769 * when we should not be forwarding packets from
770 * this dest.
771 */
772static int dn_blackhole(struct sk_buff *skb)
773{
774 kfree_skb(skb);
775 return NET_RX_DROP;
776}
777
778/*
779 * Used to catch bugs. This should never normally get 768 * Used to catch bugs. This should never normally get
780 * called. 769 * called.
781 */ 770 */
@@ -1396,7 +1385,7 @@ make_route:
1396 default: 1385 default:
1397 case RTN_UNREACHABLE: 1386 case RTN_UNREACHABLE:
1398 case RTN_BLACKHOLE: 1387 case RTN_BLACKHOLE:
1399 rt->u.dst.input = dn_blackhole; 1388 rt->u.dst.input = dst_discard;
1400 } 1389 }
1401 rt->rt_flags = flags; 1390 rt->rt_flags = flags;
1402 if (rt->u.dst.dev) 1391 if (rt->u.dst.dev)
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 49e008568ddf..137b8eb666b7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -92,6 +92,7 @@
92#include <linux/jhash.h> 92#include <linux/jhash.h>
93#include <linux/rcupdate.h> 93#include <linux/rcupdate.h>
94#include <linux/times.h> 94#include <linux/times.h>
95#include <net/dst.h>
95#include <net/net_namespace.h> 96#include <net/net_namespace.h>
96#include <net/protocol.h> 97#include <net/protocol.h>
97#include <net/ip.h> 98#include <net/ip.h>
@@ -2357,12 +2358,6 @@ static struct dst_ops ipv4_dst_blackhole_ops = {
2357}; 2358};
2358 2359
2359 2360
2360static int ipv4_blackhole_output(struct sk_buff *skb)
2361{
2362 kfree_skb(skb);
2363 return 0;
2364}
2365
2366static int ipv4_dst_blackhole(struct rtable **rp, struct flowi *flp, struct sock *sk) 2361static int ipv4_dst_blackhole(struct rtable **rp, struct flowi *flp, struct sock *sk)
2367{ 2362{
2368 struct rtable *ort = *rp; 2363 struct rtable *ort = *rp;
@@ -2374,8 +2369,8 @@ static int ipv4_dst_blackhole(struct rtable **rp, struct flowi *flp, struct sock
2374 2369
2375 atomic_set(&new->__refcnt, 1); 2370 atomic_set(&new->__refcnt, 1);
2376 new->__use = 1; 2371 new->__use = 1;
2377 new->input = ipv4_blackhole_output; 2372 new->input = dst_discard;
2378 new->output = ipv4_blackhole_output; 2373 new->output = dst_discard;
2379 memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32)); 2374 memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
2380 2375
2381 new->dev = ort->u.dst.dev; 2376 new->dev = ort->u.dst.dev;
diff --git a/net/ipv6/exthdrs.c b/net/ipv6/exthdrs.c
index 1e89efd38a0c..cee06b1655c1 100644
--- a/net/ipv6/exthdrs.c
+++ b/net/ipv6/exthdrs.c
@@ -32,6 +32,7 @@
32#include <linux/in6.h> 32#include <linux/in6.h>
33#include <linux/icmpv6.h> 33#include <linux/icmpv6.h>
34 34
35#include <net/dst.h>
35#include <net/sock.h> 36#include <net/sock.h>
36#include <net/snmp.h> 37#include <net/snmp.h>
37 38
@@ -318,18 +319,8 @@ void __init ipv6_destopt_init(void)
318 printk(KERN_ERR "ipv6_destopt_init: Could not register protocol\n"); 319 printk(KERN_ERR "ipv6_destopt_init: Could not register protocol\n");
319} 320}
320 321
321/********************************
322 NONE header. No data in packet.
323 ********************************/
324
325static int ipv6_nodata_rcv(struct sk_buff *skb)
326{
327 kfree_skb(skb);
328 return 0;
329}
330
331static struct inet6_protocol nodata_protocol = { 322static struct inet6_protocol nodata_protocol = {
332 .handler = ipv6_nodata_rcv, 323 .handler = dst_discard,
333 .flags = INET6_PROTO_NOPOLICY, 324 .flags = INET6_PROTO_NOPOLICY,
334}; 325};
335 326
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 20083e0d3995..ac70e2d3b10c 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -152,7 +152,6 @@ struct rt6_info ip6_null_entry = {
152 152
153static int ip6_pkt_prohibit(struct sk_buff *skb); 153static int ip6_pkt_prohibit(struct sk_buff *skb);
154static int ip6_pkt_prohibit_out(struct sk_buff *skb); 154static int ip6_pkt_prohibit_out(struct sk_buff *skb);
155static int ip6_pkt_blk_hole(struct sk_buff *skb);
156 155
157struct rt6_info ip6_prohibit_entry = { 156struct rt6_info ip6_prohibit_entry = {
158 .u = { 157 .u = {
@@ -181,8 +180,8 @@ struct rt6_info ip6_blk_hole_entry = {
181 .obsolete = -1, 180 .obsolete = -1,
182 .error = -EINVAL, 181 .error = -EINVAL,
183 .metrics = { [RTAX_HOPLIMIT - 1] = 255, }, 182 .metrics = { [RTAX_HOPLIMIT - 1] = 255, },
184 .input = ip6_pkt_blk_hole, 183 .input = dst_discard,
185 .output = ip6_pkt_blk_hole, 184 .output = dst_discard,
186 .ops = &ip6_dst_ops, 185 .ops = &ip6_dst_ops,
187 .path = (struct dst_entry*)&ip6_blk_hole_entry, 186 .path = (struct dst_entry*)&ip6_blk_hole_entry,
188 } 187 }
@@ -782,12 +781,6 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
782 781
783EXPORT_SYMBOL(ip6_route_output); 782EXPORT_SYMBOL(ip6_route_output);
784 783
785static int ip6_blackhole_output(struct sk_buff *skb)
786{
787 kfree_skb(skb);
788 return 0;
789}
790
791int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl) 784int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl)
792{ 785{
793 struct rt6_info *ort = (struct rt6_info *) *dstp; 786 struct rt6_info *ort = (struct rt6_info *) *dstp;
@@ -800,8 +793,8 @@ int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl
800 793
801 atomic_set(&new->__refcnt, 1); 794 atomic_set(&new->__refcnt, 1);
802 new->__use = 1; 795 new->__use = 1;
803 new->input = ip6_blackhole_output; 796 new->input = dst_discard;
804 new->output = ip6_blackhole_output; 797 new->output = dst_discard;
805 798
806 memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32)); 799 memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
807 new->dev = ort->u.dst.dev; 800 new->dev = ort->u.dst.dev;
@@ -1811,12 +1804,6 @@ static int ip6_pkt_prohibit_out(struct sk_buff *skb)
1811 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES); 1804 return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
1812} 1805}
1813 1806
1814static int ip6_pkt_blk_hole(struct sk_buff *skb)
1815{
1816 kfree_skb(skb);
1817 return 0;
1818}
1819
1820#endif 1807#endif
1821 1808
1822/* 1809/*