Skip to content

Commit 0accfc2

Browse files
tgrafdavem330
authored andcommitted
arp: Inherit metadata dst when creating ARP requests
If output device wants to see the dst, inherit the dst of the original skb and pass it on to generate the ARP request. Signed-off-by: Thomas Graf <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f38a9eb commit 0accfc2

File tree

1 file changed

+37
-28
lines changed

1 file changed

+37
-28
lines changed

net/ipv4/arp.c

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,40 @@ static void arp_error_report(struct neighbour *neigh, struct sk_buff *skb)
291291
kfree_skb(skb);
292292
}
293293

294+
/* Create and send an arp packet. */
295+
static void arp_send_dst(int type, int ptype, __be32 dest_ip,
296+
struct net_device *dev, __be32 src_ip,
297+
const unsigned char *dest_hw,
298+
const unsigned char *src_hw,
299+
const unsigned char *target_hw, struct sk_buff *oskb)
300+
{
301+
struct sk_buff *skb;
302+
303+
/* arp on this interface. */
304+
if (dev->flags & IFF_NOARP)
305+
return;
306+
307+
skb = arp_create(type, ptype, dest_ip, dev, src_ip,
308+
dest_hw, src_hw, target_hw);
309+
if (!skb)
310+
return;
311+
312+
if (oskb)
313+
skb_dst_copy(skb, oskb);
314+
315+
arp_xmit(skb);
316+
}
317+
318+
void arp_send(int type, int ptype, __be32 dest_ip,
319+
struct net_device *dev, __be32 src_ip,
320+
const unsigned char *dest_hw, const unsigned char *src_hw,
321+
const unsigned char *target_hw)
322+
{
323+
arp_send_dst(type, ptype, dest_ip, dev, src_ip, dest_hw, src_hw,
324+
target_hw, NULL);
325+
}
326+
EXPORT_SYMBOL(arp_send);
327+
294328
static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
295329
{
296330
__be32 saddr = 0;
@@ -346,8 +380,9 @@ static void arp_solicit(struct neighbour *neigh, struct sk_buff *skb)
346380
}
347381
}
348382

349-
arp_send(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr,
350-
dst_hw, dev->dev_addr, NULL);
383+
arp_send_dst(ARPOP_REQUEST, ETH_P_ARP, target, dev, saddr,
384+
dst_hw, dev->dev_addr, NULL,
385+
dev->priv_flags & IFF_XMIT_DST_RELEASE ? NULL : skb);
351386
}
352387

353388
static int arp_ignore(struct in_device *in_dev, __be32 sip, __be32 tip)
@@ -596,32 +631,6 @@ void arp_xmit(struct sk_buff *skb)
596631
}
597632
EXPORT_SYMBOL(arp_xmit);
598633

599-
/*
600-
* Create and send an arp packet.
601-
*/
602-
void arp_send(int type, int ptype, __be32 dest_ip,
603-
struct net_device *dev, __be32 src_ip,
604-
const unsigned char *dest_hw, const unsigned char *src_hw,
605-
const unsigned char *target_hw)
606-
{
607-
struct sk_buff *skb;
608-
609-
/*
610-
* No arp on this interface.
611-
*/
612-
613-
if (dev->flags&IFF_NOARP)
614-
return;
615-
616-
skb = arp_create(type, ptype, dest_ip, dev, src_ip,
617-
dest_hw, src_hw, target_hw);
618-
if (!skb)
619-
return;
620-
621-
arp_xmit(skb);
622-
}
623-
EXPORT_SYMBOL(arp_send);
624-
625634
/*
626635
* Process an arp request.
627636
*/

0 commit comments

Comments
 (0)