[openib-general] [RFC] IPoIB sockaddr_ll changes

Hal Rosenstock halr at voltaire.com
Fri Aug 5 08:42:17 PDT 2005


Hi,

I would like to get comments on this prior to sending this over to
kernel land.

There is a similar change to both:
/usr/include/linux/if_packet.h
/usr/include/netpacket/packet.h
as in:
include/linux/if_packet.h below
to increase sll_addr from 8 to 20 bytes.

Thanks.

-- Hal

IPoIB sockaddr_ll changes due to the fact that the IPoIB link layer
address is 20 bytes rather than 8 bytes

Signed-off-by: Hal Rosenstock <halr at voltaire.com>

--- include/linux/if_packet.h.orig	2005-06-29 19:00:53.000000000 -0400
+++ include/linux/if_packet.h	2005-08-05 10:04:06.000000000 -0400
@@ -8,6 +8,7 @@ struct sockaddr_pkt
 	unsigned short spkt_protocol;
 };
 
+#define SOCKADDR_LL_COMPAT	12
 struct sockaddr_ll
 {
 	unsigned short	sll_family;
@@ -16,7 +17,7 @@ struct sockaddr_ll
 	unsigned short	sll_hatype;
 	unsigned char	sll_pkttype;
 	unsigned char	sll_halen;
-	unsigned char	sll_addr[8];
+	unsigned char	sll_addr[20];
 };
 
 /* Packet types */

--- net/packet/af_packet.c.orig	2005-06-29 19:00:53.000000000 -0400
+++ net/packet/af_packet.c	2005-08-05 11:23:24.000000000 -0400
@@ -140,7 +140,7 @@ dev->hard_header == NULL (ll header is a
    mac.raw -> data
    data -> data
 
-   We should set nh.raw on output to correct posistion,
+   We should set nh.raw on output to correct position,
    packet classifier depends on it.
  */
 
@@ -315,7 +315,7 @@ static int packet_sendmsg_spkt(struct ki
 	struct net_device *dev;
 	unsigned short proto=0;
 	int err;
-	
+
 	/*
 	 *	Get and verify the address. 
 	 */
@@ -708,8 +708,11 @@ static int packet_sendmsg(struct kiocb *
 		addr	= NULL;
 	} else {
 		err = -EINVAL;
-		if (msg->msg_namelen < sizeof(struct sockaddr_ll))
-			goto out;
+		if (msg->msg_namelen < sizeof(struct sockaddr_ll)) {
+			/* Support for older sockaddr_ll structs */
+			if ((msg->msg_namelen != sizeof(struct sockaddr_ll) - SOCKADDR_LL_COMPAT) || (saddr->sll_hatype == ARPHRD_INFINIBAND))
+				goto out;
+		}
 		ifindex	= saddr->sll_ifindex;
 		proto	= saddr->sll_protocol;
 		addr	= saddr->sll_addr;
@@ -937,7 +940,9 @@ static int packet_bind(struct socket *so
 	 */
 	 
 	if (addr_len < sizeof(struct sockaddr_ll))
-		return -EINVAL;
+		if ((addr_len != sizeof(struct sockaddr_ll) - SOCKADDR_LL_COMPAT) || 
+				(sll->sll_hatype == ARPHRD_INFINIBAND))
+			return -EINVAL;
 	if (sll->sll_family != AF_PACKET)
 		return -EINVAL;
 






More information about the general mailing list