Skip to content

Commit 545ecdc

Browse files
maximlevitskydavem330
authored andcommitted
arp: allow to invalidate specific ARP entries
IPv4 over firewire needs to be able to remove ARP entries from the ARP cache that belong to nodes that are removed, because IPv4 over firewire uses ARP packets for private information about nodes. This information becomes invalid as soon as node drops off the bus and when it reconnects, its only possible to start talking to it after it responded to an ARP packet. But ARP cache prevents such packets from being sent. Signed-off-by: Maxim Levitsky <maximlevitsky@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bfe0d02 commit 545ecdc

2 files changed

Lines changed: 19 additions & 11 deletions

File tree

‎include/net/arp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
2525
const unsigned char *src_hw,
2626
const unsigned char *target_hw);
2727
extern void arp_xmit(struct sk_buff *skb);
28+
int arp_invalidate(struct net_device *dev, __be32 ip);
2829

2930
#endif /* _ARP_H */

‎net/ipv4/arp.c‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,6 +1143,23 @@ static int arp_req_get(struct arpreq *r, struct net_device *dev)
11431143
return err;
11441144
}
11451145

1146+
int arp_invalidate(struct net_device *dev, __be32 ip)
1147+
{
1148+
struct neighbour *neigh = neigh_lookup(&arp_tbl, &ip, dev);
1149+
int err = -ENXIO;
1150+
1151+
if (neigh) {
1152+
if (neigh->nud_state & ~NUD_NOARP)
1153+
err = neigh_update(neigh, NULL, NUD_FAILED,
1154+
NEIGH_UPDATE_F_OVERRIDE|
1155+
NEIGH_UPDATE_F_ADMIN);
1156+
neigh_release(neigh);
1157+
}
1158+
1159+
return err;
1160+
}
1161+
EXPORT_SYMBOL(arp_invalidate);
1162+
11461163
static int arp_req_delete_public(struct net *net, struct arpreq *r,
11471164
struct net_device *dev)
11481165
{
@@ -1163,7 +1180,6 @@ static int arp_req_delete(struct net *net, struct arpreq *r,
11631180
{
11641181
int err;
11651182
__be32 ip;
1166-
struct neighbour *neigh;
11671183

11681184
if (r->arp_flags & ATF_PUBL)
11691185
return arp_req_delete_public(net, r, dev);
@@ -1181,16 +1197,7 @@ static int arp_req_delete(struct net *net, struct arpreq *r,
11811197
if (!dev)
11821198
return -EINVAL;
11831199
}
1184-
err = -ENXIO;
1185-
neigh = neigh_lookup(&arp_tbl, &ip, dev);
1186-
if (neigh) {
1187-
if (neigh->nud_state & ~NUD_NOARP)
1188-
err = neigh_update(neigh, NULL, NUD_FAILED,
1189-
NEIGH_UPDATE_F_OVERRIDE|
1190-
NEIGH_UPDATE_F_ADMIN);
1191-
neigh_release(neigh);
1192-
}
1193-
return err;
1200+
return arp_invalidate(dev, ip);
11941201
}
11951202

11961203
/*

0 commit comments

Comments
 (0)