From 47fb3f91d8ff777ff9e9cb0cfa452364f2de0df3 Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Mon, 23 Mar 2020 15:17:57 +0800 Subject: [PATCH] net/ice/base: add check to IPv4 next protocol In order to support switch rule for NVGRE packets, it need to check ipv4 next protocol number, if it is 0x2F, which means next payload is NVGRE, we need to use NVGRE format dummy packet. Signed-off-by: Wei Zhao Signed-off-by: Qi Zhang Signed-off-by: Paul M Stillwell Jr Acked-by: Qiming Yang --- drivers/net/ice/base/ice_switch.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ice/base/ice_switch.c b/drivers/net/ice/base/ice_switch.c index 29fa9cf7e4..a7fb30b05a 100644 --- a/drivers/net/ice/base/ice_switch.c +++ b/drivers/net/ice/base/ice_switch.c @@ -10,6 +10,7 @@ #define ICE_ETH_ETHTYPE_OFFSET 12 #define ICE_ETH_VLAN_TCI_OFFSET 14 #define ICE_MAX_VLAN_ID 0xFFF +#define ICE_IPV4_NVGRE_PROTO_ID 0x002F /* Dummy ethernet header needed in the ice_aqc_sw_rules_elem * struct to configure any switch filter rules. @@ -5908,6 +5909,7 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, const struct ice_dummy_pkt_offsets **offsets) { bool tcp = false, udp = false, ipv6 = false, vlan = false; + bool gre = false; u16 i; if (tun_type == ICE_SW_TUN_GTP) { @@ -5931,6 +5933,12 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, ipv6 = true; else if (lkups[i].type == ICE_VLAN_OFOS) vlan = true; + else if (lkups[i].type == ICE_IPV4_OFOS && + lkups[i].h_u.ipv4_hdr.protocol == + ICE_IPV4_NVGRE_PROTO_ID && + lkups[i].m_u.ipv4_hdr.protocol == + 0xFF) + gre = true; } if (tun_type == ICE_ALL_TUNNELS) { @@ -5940,7 +5948,7 @@ ice_find_dummy_packet(struct ice_adv_lkup_elem *lkups, u16 lkups_cnt, return; } - if (tun_type == ICE_SW_TUN_NVGRE) { + if (tun_type == ICE_SW_TUN_NVGRE || gre) { if (tcp) { *pkt = dummy_gre_tcp_packet; *pkt_len = sizeof(dummy_gre_tcp_packet); -- 2.20.1