[ovs-dev] [PATCH] datapath: set the skb 'pkt_type' field

Tadaaki Nagao nagao at stratosphere.co.jp
Fri Sep 7 12:23:59 UTC 2012


The datapath doesn't set the skb 'pkt_type' field for packets received
from the userspace, and thus their pkt_type is always PACKET_HOST even
for Ethernet broadcast and multicast packets.  Though there don't seem
to be many users of pkt_type in the Linux kernel, I encountered a
third-party driver that relies on that field.  This patch fixes this
issue.

Signed-off-by: Tadaaki Nagao <nagao at stratosphere.co.jp>
---
 datapath/datapath.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/datapath/datapath.c b/datapath/datapath.c
index c83ce16..9857ecc 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -765,9 +765,15 @@ static int ovs_packet_cmd_execute(struct sk_buff *skb, struct genl_info *info)
 	skb_reset_mac_header(packet);
 	eth = eth_hdr(packet);
 
-	/* Normally, setting the skb 'protocol' field would be handled by a
-	 * call to eth_type_trans(), but it assumes there's a sending
-	 * device, which we may not have. */
+	/* Normally, setting the skb 'pkt_type' and 'protocol' field would
+	 * be handled by a call to eth_type_trans(), but it assumes there's
+	 * a sending device, which we may not have. */
+	if (is_multicast_ether_addr(eth->h_dest)) {
+		if (is_broadcast_ether_addr(eth->h_dest))
+			packet->pkt_type = PACKET_BROADCAST;
+		else
+			packet->pkt_type = PACKET_MULTICAST;
+	}
 	if (ntohs(eth->h_proto) >= 1536)
 		packet->protocol = eth->h_proto;
 	else
-- 
1.7.9.5




More information about the dev mailing list