Skip to content

Commit 519e513

Browse files
Vasu DevJames Bottomley
authored andcommitted
[SCSI] fcoe: adds src and dest mac address checking for fcoe frames
This is per FC-BB-5 Annex-D recommendation and per that if address checking fails then drop the frame. FIP code paths are already doing this so only needed for fcoe frames. The src address checking is limited to only fip mode since this might break non-fip mode used in p2p due to used OUI based addressing in some p2p code paths, going forward FIP will be the only mode, therefore limited this to only FIP mode so that it won't break non-fip p2p mode for now. -v2 Removes FCOE packet type checking since fcoe_rcv is registered to receive only FCoE type packets from netdev and it is already checked by netdev. Signed-off-by: Vasu Dev <vasu.dev@intel.com> Signed-off-by: Robert Love <robert.w.love@intel.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
1 parent 9d4cbc0 commit 519e513

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎drivers/scsi/fcoe/fcoe.c‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,8 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
12101210
struct fcoe_interface *fcoe;
12111211
struct fc_frame_header *fh;
12121212
struct fcoe_percpu_s *fps;
1213+
struct fcoe_port *port;
1214+
struct ethhdr *eh;
12131215
unsigned int cpu;
12141216

12151217
fcoe = container_of(ptype, struct fcoe_interface, fcoe_packet_type);
@@ -1227,9 +1229,21 @@ int fcoe_rcv(struct sk_buff *skb, struct net_device *netdev,
12271229
skb_tail_pointer(skb), skb_end_pointer(skb),
12281230
skb->csum, skb->dev ? skb->dev->name : "<NULL>");
12291231

1230-
/* check for FCOE packet type */
1231-
if (unlikely(eth_hdr(skb)->h_proto != htons(ETH_P_FCOE))) {
1232-
FCOE_NETDEV_DBG(netdev, "Wrong FC type frame");
1232+
/* check for mac addresses */
1233+
eh = eth_hdr(skb);
1234+
port = lport_priv(lport);
1235+
if (compare_ether_addr(eh->h_dest, port->data_src_addr) &&
1236+
compare_ether_addr(eh->h_dest, fcoe->ctlr.ctl_src_addr) &&
1237+
compare_ether_addr(eh->h_dest, (u8[6])FC_FCOE_FLOGI_MAC)) {
1238+
FCOE_NETDEV_DBG(netdev, "wrong destination mac address:%pM\n",
1239+
eh->h_dest);
1240+
goto err;
1241+
}
1242+
1243+
if (is_fip_mode(&fcoe->ctlr) &&
1244+
compare_ether_addr(eh->h_source, fcoe->ctlr.dest_addr)) {
1245+
FCOE_NETDEV_DBG(netdev, "wrong source mac address:%pM\n",
1246+
eh->h_source);
12331247
goto err;
12341248
}
12351249

‎include/scsi/libfcoe.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,4 +170,14 @@ int fcoe_ctlr_recv_flogi(struct fcoe_ctlr *, struct fc_lport *,
170170
u64 fcoe_wwn_from_mac(unsigned char mac[], unsigned int, unsigned int);
171171
int fcoe_libfc_config(struct fc_lport *, struct libfc_function_template *);
172172

173+
/**
174+
* is_fip_mode() - returns true if FIP mode selected.
175+
* @fip: FCoE controller.
176+
*/
177+
static inline bool is_fip_mode(struct fcoe_ctlr *fip)
178+
{
179+
return fip->state == FIP_ST_ENABLED;
180+
}
181+
182+
173183
#endif /* _LIBFCOE_H */

0 commit comments

Comments
 (0)