Some switches encapsulate the vlan discovery replies in a vlan 0 tag and
the vlan tag may or may not be stripped by the ethx device. Update the
parsing logic to skip over the vlan header and point to the correct
start of the FIP header.

Signed-off-by: Nithin Nayak Sujir <[email protected]>
---
 include/fip.h |    2 ++
 lib/fip.c     |    6 +++++-
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/include/fip.h b/include/fip.h
index 2b00b7c..226301e 100644
--- a/include/fip.h
+++ b/include/fip.h
@@ -26,6 +26,8 @@
 #define ETH_P_FCOE     0x8906
 #define ETH_P_FIP      0x8914
 
+#define VLAN_HLEN 4
+
 #define FIP_ALL_FCOE_MACS      { 0x01, 0x10, 0x18, 0x01, 0x00, 0x00 }
 #define FIP_ALL_ENODE_MACS     { 0x01, 0x10, 0x18, 0x01, 0x00, 0x01 }
 #define FIP_ALL_FCF_MACS       { 0x01, 0x10, 0x18, 0x01, 0x00, 0x02 }
diff --git a/lib/fip.c b/lib/fip.c
index 20c1082..52d2802 100644
--- a/lib/fip.c
+++ b/lib/fip.c
@@ -273,6 +273,7 @@ int fip_recv(int s, fip_handler *fn, void *arg)
        };
        struct fiphdr *fh;
        ssize_t len, desc_len;
+       struct ethhdr *eth = (struct ethhdr *)buf;
 
        len = recvmsg(s, &msg, MSG_DONTWAIT);
        if (len < 0) {
@@ -285,7 +286,10 @@ int fip_recv(int s, fip_handler *fn, void *arg)
                return -1;
        }
 
-       fh = (struct fiphdr *) (buf + sizeof(struct ethhdr));
+       if (eth->h_proto == htons(ETH_P_8021Q))
+               fh = (struct fiphdr *) (buf + sizeof(struct ethhdr) + 
VLAN_HLEN);
+       else
+               fh = (struct fiphdr *) (buf + sizeof(struct ethhdr));
 
        desc_len = ntohs(fh->fip_desc_len);
        if (len < (sizeof(*fh) + (desc_len << 2))) {
-- 
1.7.1


_______________________________________________
devel mailing list
[email protected]
https://lists.open-fcoe.org/mailman/listinfo/devel

Reply via email to