Skip to content

Commit d242e66

Browse files
hreineckemartinkpetersen
authored andcommitted
fcoe: Use default VLAN for FIP VLAN discovery
FC-BB-6 states: FIP protocols shall be performed on a per-VLAN basis. It is recommended to use the FIP VLAN discovery protocol on the default VLAN. Signed-off-by: Hannes Reinecke <hare@suse.com> Acked-by: Johannes Thumshirn <jth@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent b195d5e commit d242e66

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

drivers/scsi/fcoe/fcoe.c

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ static struct fcoe_interface
9292

9393
static int fcoe_fip_recv(struct sk_buff *, struct net_device *,
9494
struct packet_type *, struct net_device *);
95+
static int fcoe_fip_vlan_recv(struct sk_buff *, struct net_device *,
96+
struct packet_type *, struct net_device *);
9597

9698
static void fcoe_fip_send(struct fcoe_ctlr *, struct sk_buff *);
9799
static void fcoe_update_src_mac(struct fc_lport *, u8 *);
@@ -363,6 +365,12 @@ static int fcoe_interface_setup(struct fcoe_interface *fcoe,
363365
fcoe->fip_packet_type.dev = netdev;
364366
dev_add_pack(&fcoe->fip_packet_type);
365367

368+
if (netdev != real_dev) {
369+
fcoe->fip_vlan_packet_type.func = fcoe_fip_vlan_recv;
370+
fcoe->fip_vlan_packet_type.type = htons(ETH_P_FIP);
371+
fcoe->fip_vlan_packet_type.dev = real_dev;
372+
dev_add_pack(&fcoe->fip_vlan_packet_type);
373+
}
366374
return 0;
367375
}
368376

@@ -450,6 +458,8 @@ static void fcoe_interface_remove(struct fcoe_interface *fcoe)
450458
*/
451459
__dev_remove_pack(&fcoe->fcoe_packet_type);
452460
__dev_remove_pack(&fcoe->fip_packet_type);
461+
if (netdev != fcoe->realdev)
462+
__dev_remove_pack(&fcoe->fip_vlan_packet_type);
453463
synchronize_net();
454464

455465
/* Delete secondary MAC addresses */
@@ -519,6 +529,29 @@ static int fcoe_fip_recv(struct sk_buff *skb, struct net_device *netdev,
519529
return 0;
520530
}
521531

532+
/**
533+
* fcoe_fip_vlan_recv() - Handler for received FIP VLAN discovery frames
534+
* @skb: The receive skb
535+
* @netdev: The associated net device
536+
* @ptype: The packet_type structure which was used to register this handler
537+
* @orig_dev: The original net_device the the skb was received on.
538+
* (in case dev is a bond)
539+
*
540+
* Returns: 0 for success
541+
*/
542+
static int fcoe_fip_vlan_recv(struct sk_buff *skb, struct net_device *netdev,
543+
struct packet_type *ptype,
544+
struct net_device *orig_dev)
545+
{
546+
struct fcoe_interface *fcoe;
547+
struct fcoe_ctlr *ctlr;
548+
549+
fcoe = container_of(ptype, struct fcoe_interface, fip_vlan_packet_type);
550+
ctlr = fcoe_to_ctlr(fcoe);
551+
fcoe_ctlr_recv(ctlr, skb);
552+
return 0;
553+
}
554+
522555
/**
523556
* fcoe_port_send() - Send an Ethernet-encapsulated FIP/FCoE frame
524557
* @port: The FCoE port
@@ -539,7 +572,21 @@ static void fcoe_port_send(struct fcoe_port *port, struct sk_buff *skb)
539572
*/
540573
static void fcoe_fip_send(struct fcoe_ctlr *fip, struct sk_buff *skb)
541574
{
542-
skb->dev = fcoe_from_ctlr(fip)->netdev;
575+
struct fcoe_interface *fcoe = fcoe_from_ctlr(fip);
576+
struct fip_frame {
577+
struct ethhdr eth;
578+
struct fip_header fip;
579+
} __packed *frame;
580+
581+
/*
582+
* Use default VLAN for FIP VLAN discovery protocol
583+
*/
584+
frame = (struct fip_frame *)skb->data;
585+
if (frame->fip.fip_op == ntohs(FIP_OP_VLAN) &&
586+
fcoe->realdev != fcoe->netdev)
587+
skb->dev = fcoe->realdev;
588+
else
589+
skb->dev = fcoe->netdev;
543590
fcoe_port_send(lport_priv(fip->lp), skb);
544591
}
545592

drivers/scsi/fcoe/fcoe.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct fcoe_interface {
8080
struct net_device *realdev;
8181
struct packet_type fcoe_packet_type;
8282
struct packet_type fip_packet_type;
83+
struct packet_type fip_vlan_packet_type;
8384
struct fc_exch_mgr *oem;
8485
u8 removed;
8586
u8 priority;

0 commit comments

Comments
 (0)