Commit bdf53c58 authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

neigh: Don't require dst in neigh_hh_init

- 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: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 59b2af26
...@@ -193,6 +193,7 @@ struct neigh_table { ...@@ -193,6 +193,7 @@ struct neigh_table {
int family; int family;
int entry_size; int entry_size;
int key_len; int key_len;
__be16 protocol;
__u32 (*hash)(const void *pkey, __u32 (*hash)(const void *pkey,
const struct net_device *dev, const struct net_device *dev,
__u32 *hash_rnd); __u32 *hash_rnd);
......
...@@ -1263,10 +1263,10 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl, ...@@ -1263,10 +1263,10 @@ struct neighbour *neigh_event_ns(struct neigh_table *tbl,
EXPORT_SYMBOL(neigh_event_ns); EXPORT_SYMBOL(neigh_event_ns);
/* called with read_lock_bh(&n->lock); */ /* 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; struct net_device *dev = n->dev;
__be16 prot = dst->ops->protocol; __be16 prot = n->tbl->protocol;
struct hh_cache *hh = &n->hh; struct hh_cache *hh = &n->hh;
write_lock_bh(&n->lock); write_lock_bh(&n->lock);
...@@ -1296,7 +1296,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb) ...@@ -1296,7 +1296,7 @@ int neigh_resolve_output(struct neighbour *neigh, struct sk_buff *skb)
unsigned int seq; unsigned int seq;
if (dev->header_ops->cache && !neigh->hh.hh_len) if (dev->header_ops->cache && !neigh->hh.hh_len)
neigh_hh_init(neigh, dst); neigh_hh_init(neigh);
do { do {
__skb_pull(skb, skb_network_offset(skb)); __skb_pull(skb, skb_network_offset(skb));
......
...@@ -97,6 +97,7 @@ struct neigh_table dn_neigh_table = { ...@@ -97,6 +97,7 @@ struct neigh_table dn_neigh_table = {
.family = PF_DECnet, .family = PF_DECnet,
.entry_size = NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)), .entry_size = NEIGH_ENTRY_SIZE(sizeof(struct dn_neigh)),
.key_len = sizeof(__le16), .key_len = sizeof(__le16),
.protocol = cpu_to_be16(ETH_P_DNA_RT),
.hash = dn_neigh_hash, .hash = dn_neigh_hash,
.constructor = dn_neigh_construct, .constructor = dn_neigh_construct,
.id = "dn_neigh_cache", .id = "dn_neigh_cache",
......
...@@ -152,6 +152,7 @@ static const struct neigh_ops arp_direct_ops = { ...@@ -152,6 +152,7 @@ static const struct neigh_ops arp_direct_ops = {
struct neigh_table arp_tbl = { struct neigh_table arp_tbl = {
.family = AF_INET, .family = AF_INET,
.key_len = 4, .key_len = 4,
.protocol = cpu_to_be16(ETH_P_IP),
.hash = arp_hash, .hash = arp_hash,
.constructor = arp_constructor, .constructor = arp_constructor,
.proxy_redo = parp_redo, .proxy_redo = parp_redo,
......
...@@ -117,6 +117,7 @@ static const struct neigh_ops ndisc_direct_ops = { ...@@ -117,6 +117,7 @@ static const struct neigh_ops ndisc_direct_ops = {
struct neigh_table nd_tbl = { struct neigh_table nd_tbl = {
.family = AF_INET6, .family = AF_INET6,
.key_len = sizeof(struct in6_addr), .key_len = sizeof(struct in6_addr),
.protocol = cpu_to_be16(ETH_P_IPV6),
.hash = ndisc_hash, .hash = ndisc_hash,
.constructor = ndisc_constructor, .constructor = ndisc_constructor,
.pconstructor = pndisc_constructor, .pconstructor = pndisc_constructor,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment