From 56ffd3a0500e3b0c133da451036074fd0a8c3f1c Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:32 -0700 Subject: scsi: bnx2fc: Add filters to the non-offload FCoE receive path. Add the following filters to bnx2fc_recv_frame(): 1. Filter out invalid packets - eth->dest_mac[3] matches FC frame's D_ID 2. Filter out packets that are not from our connected target - In FIP_ST_ENABLED mode - eth->src_mac matches fcoe_ctlr->dest_addr 3. Filter out packets where if d_id of the packet doesn't belong to the device when one is already assigned a port_id, only then this packet is dropped Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 902722dc4ce3..342a316d9341 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -522,10 +522,12 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) struct fcoe_crc_eof crc_eof; struct fc_frame *fp; struct fc_lport *vn_port; - struct fcoe_port *port; + struct fcoe_port *port, *phys_port; u8 *mac = NULL; u8 *dest_mac = NULL; struct fcoe_hdr *hp; + struct bnx2fc_interface *interface; + struct fcoe_ctlr *ctlr; fr = fcoe_dev_from_skb(skb); lport = fr->fr_dev; @@ -561,8 +563,19 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } + phys_port = lport_priv(lport); + interface = phys_port->priv; + ctlr = bnx2fc_to_ctlr(interface); + fh = fc_frame_header_get(fp); + if (ntoh24(&dest_mac[3]) != ntoh24(fh->fh_d_id)) { + BNX2FC_HBA_DBG(lport, "FC frame d_id mismatch with MAC %pM.\n", + dest_mac); + kfree_skb(skb); + return; + } + vn_port = fc_vport_id_lookup(lport, ntoh24(fh->fh_d_id)); if (vn_port) { port = lport_priv(vn_port); @@ -572,6 +585,14 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } } + if (ctlr->state) { + if (!ether_addr_equal(mac, ctlr->dest_addr)) { + BNX2FC_HBA_DBG(lport, "Wrong source address: mac:%pM dest_addr:%pM.\n", + mac, ctlr->dest_addr); + kfree_skb(skb); + return; + } + } if (fh->fh_r_ctl == FC_RCTL_DD_SOL_DATA && fh->fh_type == FC_TYPE_FCP) { /* Drop FCP data. We dont this in L2 path */ @@ -597,6 +618,18 @@ static void bnx2fc_recv_frame(struct sk_buff *skb) return; } + /* + * If the destination ID from the frame header does not match what we + * have on record for lport and the search for a NPIV port came up + * empty then this is not addressed to our port so simply drop it. + */ + if (lport->port_id != ntoh24(fh->fh_d_id) && !vn_port) { + BNX2FC_HBA_DBG(lport, "Dropping frame due to destination mismatch: lport->port_id=%x fh->d_id=%x.\n", + lport->port_id, ntoh24(fh->fh_d_id)); + kfree_skb(skb); + return; + } + stats = per_cpu_ptr(lport->stats, smp_processor_id()); stats->RxFrames++; stats->RxWords += fr_len / FCOE_WORD_TO_BYTE; -- cgit From 21144b80619fc953bcf3615252960f2cdf846883 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:34 -0700 Subject: scsi: bnx2fc: Update copyright for 2017. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 342a316d9341..0d313a15e677 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -4,7 +4,8 @@ * FIP/FCoE packets, listen to link events etc. * * Copyright (c) 2008-2013 Broadcom Corporation - * Copyright (c) 2014-2015 QLogic Corporation + * Copyright (c) 2014-2016 QLogic Corporation + * Copyright (c) 2016-2017 Cavium Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by -- cgit From 59fb870f0ed4da64cbbc44f6a4dc1038be9f8904 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:35 -0700 Subject: scsi: bnx2fc: Adjust bnx2fc_npiv_create_vports for WWNNs from NVRAM that are zero. Some vports addresses stored in NVRAM may have zero for the WWNN. Adjust the WWNN that we'll use to be the same as the WWPN. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 0d313a15e677..71dd36756ca4 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2139,6 +2139,9 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport *lport, { struct fc_vport_identifiers vpid; uint i, created = 0; + u64 wwnn = 0; + char wwpn_str[32]; + char wwnn_str[32]; if (npiv_tbl->count > MAX_NPIV_ENTRIES) { BNX2FC_HBA_DBG(lport, "Exceeded count max of npiv table\n"); @@ -2157,11 +2160,23 @@ static uint bnx2fc_npiv_create_vports(struct fc_lport *lport, vpid.disable = false; for (i = 0; i < npiv_tbl->count; i++) { - vpid.node_name = wwn_to_u64(npiv_tbl->wwnn[i]); + wwnn = wwn_to_u64(npiv_tbl->wwnn[i]); + if (wwnn == 0) { + /* + * If we get a 0 element from for the WWNN then assume + * the WWNN should be the same as the physical port. + */ + wwnn = lport->wwnn; + } + vpid.node_name = wwnn; vpid.port_name = wwn_to_u64(npiv_tbl->wwpn[i]); scnprintf(vpid.symbolic_name, sizeof(vpid.symbolic_name), "NPIV[%u]:%016llx-%016llx", created, vpid.port_name, vpid.node_name); + fcoe_wwn_to_str(vpid.node_name, wwnn_str, sizeof(wwnn_str)); + fcoe_wwn_to_str(vpid.port_name, wwpn_str, sizeof(wwpn_str)); + BNX2FC_HBA_DBG(lport, "Creating vport %s:%s.\n", wwnn_str, + wwpn_str); if (fc_vport_create(lport->host, 0, &vpid)) created++; else -- cgit From 5eddc3358f6e2e2e7c56a24a75566c90ca207303 Mon Sep 17 00:00:00 2001 From: Chad Dupuis Date: Mon, 26 Jun 2017 08:59:37 -0700 Subject: scsi: bnx2fc: Make rport_terminate_io callback a NOOP. Do not call the stock libfc terminate rport i/o handler so we won't reset the libfc exchange manager and kill any outstanding discovery requests. Signed-off-by: Chad Dupuis Signed-off-by: Martin K. Petersen --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c') diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 71dd36756ca4..b1c105f4130d 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -2573,6 +2573,11 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev) bnx2fc_hba_destroy(hba); } +static void bnx2fc_rport_terminate_io(struct fc_rport *rport) +{ + /* This is a no-op */ +} + /** * bnx2fc_fcoe_reset - Resets the fcoe * @@ -2909,7 +2914,7 @@ static struct fc_function_template bnx2fc_transport_function = { .issue_fc_host_lip = bnx2fc_fcoe_reset, - .terminate_rport_io = fc_rport_terminate_io, + .terminate_rport_io = bnx2fc_rport_terminate_io, .vport_create = bnx2fc_vport_create, .vport_delete = bnx2fc_vport_destroy, -- cgit