neigh: Don't require dst in neigh_hh_init
authorEric W. Biederman <ebiederm@xmission.com>
Mon, 2 Mar 2015 06:13:22 +0000 (00:13 -0600)
committerDavid S. Miller <davem@davemloft.net>
Mon, 2 Mar 2015 21:43:41 +0000 (16:43 -0500)
- Add protocol to neigh_tbl so that dst->ops->protocol is not needed
- Acquire the device from neigh->dev

This results in a neigh_hh_init that will cache the samve values
regardless of the packets flowing through it.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/neighbour.h
net/core/neighbour.c
net/decnet/dn_neigh.c
net/ipv4/arp.c
net/ipv6/ndisc.c

index bc66babb5f27f85d32dea1d1ad042cb284faa0ee..9f912e4d4232d1b5a5ec1ab3f7ef51d0cac730e5 100644 (file)
@@ -193,6 +193,7 @@ struct neigh_table {
        int                     family;
        int                     entry_size;
        int                     key_len;
+       __be16                  protocol;
        __u32                   (*hash)(const void *pkey,
                                        const struct net_device *dev,
                                        __u32 *hash_rnd);
index 8a319ff3e8d1edab66b65caaa9e29384423c3e1d..af72b863e96887c73a05a44f1673216ea14ac973 100644 (file)
@@ -1263,10 +1263,10 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl,
 EXPORT_SYMBOL(neigh_event_ns);
 
 /* called with read_lock_bh(&n->lock); */
-static void neigh_hh_init(struct neighbour *n, struct dst_entry *dst)
+static void neigh_hh_init(struct neighbour *n)
 {
-       struct net_device *dev = dst->dev;
-       __be16 prot = dst->ops->protocol;
+       struct net_device *dev = n->dev;
+       __be16 prot = n->tbl->protocol;
        struct hh_cache *hh = &n->hh;
 
        write_lock_bh(&n->lock);
@@ -1296,7 +1296,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
                unsigned int seq;
 
                if (dev->header_ops->cache && !neigh->hh.hh_len)
-                       neigh_hh_init(neigh, dst);
+                       neigh_hh_init(neigh);
 
                do {
                        __skb_pull(skb, skb_network_offset(skb));
index 7ca7c3143da332d567bd336197beff18ce210083..f123c6c6748c10b98e7e7500c108936dc634a128 100644 (file)
@@ -97,6 +97,7 @@ struct neigh_table dn_neigh_table = {
        .family =                       PF_DECnet,
        .entry_size =                   NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)),
        .key_len =                      sizeof(__le16),
+       .protocol =                     cpu_to_be16(ETH_P_DNA_RT),
        .hash =                         dn_neigh_hash,
        .constructor =                  dn_neigh_construct,
        .id =                           "dn_neigh_cache",
index bca5b9d9b4423225998b75a2d042d4d9203e4d6f..6b8aad6a0d7dd2b28c6d52d16b3357136a73241b 100644 (file)
@@ -152,6 +152,7 @@ static const struct neigh_ops arp_direct_ops = {
 struct neigh_table arp_tbl = {
        .family         = AF_INET,
        .key_len        = 4,
+       .protocol       = cpu_to_be16(ETH_P_IP),
        .hash           = arp_hash,
        .constructor    = arp_constructor,
        .proxy_redo     = parp_redo,
index 471ed24aabaec4b1d8736438696ca3490d4e0f58..e363bbc2420d8dec7e4d3c4626ac089513d0a04e 100644 (file)
@@ -117,6 +117,7 @@ static const struct neigh_ops ndisc_direct_ops = {
 struct neigh_table nd_tbl = {
        .family =       AF_INET6,
        .key_len =      sizeof(struct in6_addr),
+       .protocol =     cpu_to_be16(ETH_P_IPV6),
        .hash =         ndisc_hash,
        .constructor =  ndisc_constructor,
        .pconstructor = pndisc_constructor,