* [PATCH] NET: Add packet sock option to return orig_dev to userspace when bonded
@ 2007-03-09 2:17 Waskiewicz Jr, Peter P
2007-04-20 23:05 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Waskiewicz Jr, Peter P @ 2007-03-09 2:17 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-kernel, Leech, Christopher, jgarzik
This patch applies against commit
704e0b01791bfcb75355f269a6f0054a75c9c563
of branch 'master' from davem/net-2.6.22
---
Summary:
Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>
NET: Add packet sock option to return orig_dev to userspace when
bonded
---
Add a packet socket option to allow the orig_dev index to be returned to
userspace when passing traffic through a bonded device. This is very
useful
for layer 2 traffic being able to report which physical device actually
received the traffic, instead of having the bond hide that information.
The new option is called PACKET_BONDED_ORIGDEV.
Signed-off-by: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>
---
include/linux/if_packet.h | 1 +
net/packet/af_packet.c | 34 +++++++++++++++++++++++++++++++---
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/include/linux/if_packet.h b/include/linux/if_packet.h
index f3de05c..b68c177 100644
--- a/include/linux/if_packet.h
+++ b/include/linux/if_packet.h
@@ -42,6 +42,7 @@ struct sockaddr_ll
#define PACKET_STATISTICS 6
#define PACKET_COPY_THRESH 7
#define PACKET_AUXDATA 8
+#define PACKET_BONDED_ORIGDEV 9
struct tpacket_stats
{
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index f9866a8..05e53a0 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -201,7 +201,8 @@ struct packet_sock {
struct packet_type prot_hook;
spinlock_t bind_lock;
unsigned int running:1, /* prot_hook is
attached*/
- auxdata:1;
+ auxdata:1,
+ origdev:1; /* return orig_dev for
bonds */
int ifindex; /* bound device
*/
__be16 num;
#ifdef CONFIG_PACKET_MULTICAST
@@ -528,7 +529,11 @@ static int packet_rcv(struct sk_buff *sk
sll->sll_hatype = dev->type;
sll->sll_protocol = skb->protocol;
sll->sll_pkttype = skb->pkt_type;
- sll->sll_ifindex = dev->ifindex;
+ /* Look at all traffic types bound for us - includes BC and MC
*/
+ if (unlikely(po->origdev) && skb->pkt_type == PACKET_HOST)
+ sll->sll_ifindex = orig_dev->ifindex;
+ else
+ sll->sll_ifindex = dev->ifindex;
sll->sll_halen = 0;
if (dev->hard_header_parse)
@@ -673,7 +678,11 @@ static int tpacket_rcv(struct sk_buff *s
sll->sll_hatype = dev->type;
sll->sll_protocol = skb->protocol;
sll->sll_pkttype = skb->pkt_type;
- sll->sll_ifindex = dev->ifindex;
+ /* Look at all traffic types bound for us - includes BC and MC
*/
+ if (unlikely(po->origdev) && skb->pkt_type == PACKET_HOST)
+ sll->sll_ifindex = orig_dev->ifindex;
+ else
+ sll->sll_ifindex = dev->ifindex;
h->tp_status = status;
smp_mb();
@@ -1413,6 +1422,18 @@ packet_setsockopt(struct socket *sock, i
po->auxdata = !!val;
return 0;
}
+ case PACKET_BONDED_ORIGDEV:
+ {
+ int val;
+
+ if (optlen < sizeof(val))
+ return -EINVAL;
+ if (copy_from_user(&val, optval, sizeof(val)))
+ return -EFAULT;
+
+ po->origdev = !!val;
+ return 0;
+ }
default:
return -ENOPROTOOPT;
}
@@ -1456,6 +1477,13 @@ static int packet_getsockopt(struct sock
data = &val;
break;
+ case PACKET_BONDED_ORIGDEV:
+ if (len > sizeof(int))
+ len = sizeof(int);
+ val = po->origdev;
+
+ data = &val;
+ break;
default:
return -ENOPROTOOPT;
}
--
Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] NET: Add packet sock option to return orig_dev to userspace when bonded
2007-03-09 2:17 [PATCH] NET: Add packet sock option to return orig_dev to userspace when bonded Waskiewicz Jr, Peter P
@ 2007-04-20 23:05 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-04-20 23:05 UTC (permalink / raw)
To: peter.p.waskiewicz.jr; +Cc: netdev, linux-kernel, christopher.leech, jgarzik
From: "Waskiewicz Jr, Peter P" <peter.p.waskiewicz.jr@intel.com>
Date: Thu, 8 Mar 2007 18:17:39 -0800
> Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>
> NET: Add packet sock option to return orig_dev to userspace when
> bonded
I'm going to apply this patch (by hand, your email client corrupted
the patch massively, adding newlines and whatnot all over the patch).
But I'm going to rename the option to be just PACKET_ORIGDEV
because although bonding is the only user of this orig_dev
decapsulation method, that might not always be true and it'd
be a shame to give a special cased name when it is not deserved
here.
But please do fix your email client for future patch submissions.
Thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-04-20 23:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-09 2:17 [PATCH] NET: Add packet sock option to return orig_dev to userspace when bonded Waskiewicz Jr, Peter P
2007-04-20 23:05 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®