]> pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[NET]: Eliminate duplicate copies of dst_discard
authorHerbert Xu <herbert@gondor.apana.org.au>
Wed, 14 Nov 2007 05:34:06 +0000 (21:34 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 22:53:37 +0000 (14:53 -0800)
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>
include/net/dst.h
net/core/dst.c
net/decnet/dn_route.c
net/ipv4/route.c
net/ipv6/exthdrs.c
net/ipv6/route.c

index 69888f1502b1724e7de331ddba2510c639768d07..7a0b1bde8e28387663b3e22ff1e73855f3a7d199 100644 (file)
@@ -179,6 +179,7 @@ static inline struct dst_entry *dst_pop(struct dst_entry *dst)
        return child;
 }
 
+extern int dst_discard(struct sk_buff *skb);
 extern void * dst_alloc(struct dst_ops * ops);
 extern void __dst_free(struct dst_entry * dst);
 extern struct dst_entry *dst_destroy(struct dst_entry * dst);
index 03daead3592ad0ef60628e85eef11e18da28b610..f538061f4b93c22358969e370d6beca4e1b28780 100644 (file)
@@ -153,11 +153,12 @@ loop:
 #endif
 }
 
-static int dst_discard(struct sk_buff *skb)
+int dst_discard(struct sk_buff *skb)
 {
        kfree_skb(skb);
        return 0;
 }
+EXPORT_SYMBOL(dst_discard);
 
 void * dst_alloc(struct dst_ops * ops)
 {
index 23aa3556e56f18f605824dddfac5feba7169c161..2a5bb0714c7ee14ed77f5860a6ad10776e3f01d1 100644 (file)
@@ -764,17 +764,6 @@ drop:
        return NET_RX_DROP;
 }
 
-/*
- * Drop packet. This is used for endnodes and for
- * when we should not be forwarding packets from
- * this dest.
- */
-static int dn_blackhole(struct sk_buff *skb)
-{
-       kfree_skb(skb);
-       return NET_RX_DROP;
-}
-
 /*
  * Used to catch bugs. This should never normally get
  * called.
@@ -1396,7 +1385,7 @@ make_route:
                default:
                case RTN_UNREACHABLE:
                case RTN_BLACKHOLE:
-                       rt->u.dst.input = dn_blackhole;
+                       rt->u.dst.input = dst_discard;
        }
        rt->rt_flags = flags;
        if (rt->u.dst.dev)
index 49e008568ddfcdbfb4f4f2c262e46bf1b463a196..137b8eb666b780d8718624b078fb1ae3270d8412 100644 (file)
@@ -92,6 +92,7 @@
 #include <linux/jhash.h>
 #include <linux/rcupdate.h>
 #include <linux/times.h>
+#include <net/dst.h>
 #include <net/net_namespace.h>
 #include <net/protocol.h>
 #include <net/ip.h>
@@ -2357,12 +2358,6 @@ static struct dst_ops ipv4_dst_blackhole_ops = {
 };
 
 
-static int ipv4_blackhole_output(struct sk_buff *skb)
-{
-       kfree_skb(skb);
-       return 0;
-}
-
 static int ipv4_dst_blackhole(struct rtable **rp, struct flowi *flp, struct sock *sk)
 {
        struct rtable *ort = *rp;
@@ -2374,8 +2369,8 @@ static int ipv4_dst_blackhole(struct rtable **rp, struct flowi *flp, struct sock
 
                atomic_set(&new->__refcnt, 1);
                new->__use = 1;
-               new->input = ipv4_blackhole_output;
-               new->output = ipv4_blackhole_output;
+               new->input = dst_discard;
+               new->output = dst_discard;
                memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
 
                new->dev = ort->u.dst.dev;
index 1e89efd38a0c6094317495cce83e9add082e69f5..cee06b1655c1311c009cc7ce426d35a82b720654 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/in6.h>
 #include <linux/icmpv6.h>
 
+#include <net/dst.h>
 #include <net/sock.h>
 #include <net/snmp.h>
 
@@ -318,18 +319,8 @@ void __init ipv6_destopt_init(void)
                printk(KERN_ERR "ipv6_destopt_init: Could not register protocol\n");
 }
 
-/********************************
-  NONE header. No data in packet.
- ********************************/
-
-static int ipv6_nodata_rcv(struct sk_buff *skb)
-{
-       kfree_skb(skb);
-       return 0;
-}
-
 static struct inet6_protocol nodata_protocol = {
-       .handler        =       ipv6_nodata_rcv,
+       .handler        =       dst_discard,
        .flags          =       INET6_PROTO_NOPOLICY,
 };
 
index 20083e0d3995cf13fcb3c3853b04925c3b2612bc..ac70e2d3b10c76bb0a1a21cc1f39127d63d56642 100644 (file)
@@ -152,7 +152,6 @@ struct rt6_info ip6_null_entry = {
 
 static int ip6_pkt_prohibit(struct sk_buff *skb);
 static int ip6_pkt_prohibit_out(struct sk_buff *skb);
-static int ip6_pkt_blk_hole(struct sk_buff *skb);
 
 struct rt6_info ip6_prohibit_entry = {
        .u = {
@@ -181,8 +180,8 @@ struct rt6_info ip6_blk_hole_entry = {
                        .obsolete       = -1,
                        .error          = -EINVAL,
                        .metrics        = { [RTAX_HOPLIMIT - 1] = 255, },
-                       .input          = ip6_pkt_blk_hole,
-                       .output         = ip6_pkt_blk_hole,
+                       .input          = dst_discard,
+                       .output         = dst_discard,
                        .ops            = &ip6_dst_ops,
                        .path           = (struct dst_entry*)&ip6_blk_hole_entry,
                }
@@ -782,12 +781,6 @@ struct dst_entry * ip6_route_output(struct sock *sk, struct flowi *fl)
 
 EXPORT_SYMBOL(ip6_route_output);
 
-static int ip6_blackhole_output(struct sk_buff *skb)
-{
-       kfree_skb(skb);
-       return 0;
-}
-
 int ip6_dst_blackhole(struct sock *sk, struct dst_entry **dstp, struct flowi *fl)
 {
        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
 
                atomic_set(&new->__refcnt, 1);
                new->__use = 1;
-               new->input = ip6_blackhole_output;
-               new->output = ip6_blackhole_output;
+               new->input = dst_discard;
+               new->output = dst_discard;
 
                memcpy(new->metrics, ort->u.dst.metrics, RTAX_MAX*sizeof(u32));
                new->dev = ort->u.dst.dev;
@@ -1811,12 +1804,6 @@ static int ip6_pkt_prohibit_out(struct sk_buff *skb)
        return ip6_pkt_drop(skb, ICMPV6_ADM_PROHIBITED, IPSTATS_MIB_OUTNOROUTES);
 }
 
-static int ip6_pkt_blk_hole(struct sk_buff *skb)
-{
-       kfree_skb(skb);
-       return 0;
-}
-
 #endif
 
 /*