Skip to contentSkip to conversation

iavf: validate dest MAC and VLAN from tc-filter code path

PATCH In review Jun Zhang 4 participants 9 messages Jun 17, 2022 – Aug 2, 2022

Subsystems (2)
lore
Share & tools
lore

Jun Zhang

author
#0 lore raw

PATCH 1/1 iavf: validate dest MAC and VLAN from tc-filter code path

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 ++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +61 -1
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16 vlan)
+{
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const u8 *macaddr)
+{
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure
@@ -3651,7 +3693,15 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */
@@ -3660,6 +3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) ||
@@ -3677,6 +3728,8 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
Signature · 6 lines
2.35.3

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
#1 lore raw
Quoted 29 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 ++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +5 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3575

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+ * Using specified "vlan" ID, there must be active VLAN filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16 vlan)
+{
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 85 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +46 -1
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const u8 *macaddr)
+{
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure
@@ -3651,7 +3693,15 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */
@@ -3660,6 +3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) ||
@@ -3677,6 +3728,8 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
Signature · 6 lines
2.35.3

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#2 lore raw

Hi Michal,

Pls add your comments whenever you have a chance.

Regards,

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Sunday, June 19, 2022 10:33 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 33 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 
++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using 
+VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in 

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3577

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16 
+vlan) {
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 83 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +38 -1
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC 
+addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in 
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const u8 
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure
@@ -3651,7 +3693,15 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */ @@ -3660,6 +3710,7 

@@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) || @@ -3677,6 +3728,8 @@ 

static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -1
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#3 lore raw
Quoted 1 line · Xuejun

Hi Michal,

Hi Jun

Quoted 2 lines

Pls add your comments whenever you have a chance.

Sorry, I am confused, comments about what? Did I miss replay to my previous one? I didn't receive any replay to my question about why we need this spin lock when there is only check for filter.

Please resend it to me if You can.

Regards
Michal

Quoted 141 lines

Regards,

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Sunday, June 19, 2022 10:33 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 33 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 
++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using 
+VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in 

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3577

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16 
+vlan) {
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 83 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +38 -1
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC 
+addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in 
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const u8 
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure
@@ -3651,7 +3693,15 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */ @@ -3660,6 +3710,7 

@@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) || @@ -3677,6 +3728,8 @@ 

static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -1
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#4 lore raw

Hi Michal,

Thanks for the reply.

The lock is access lock for both mac_filter_list & vlan_filter_list. Access to anyone of the two filter lists requires holding the lock per current code design.

Regards

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Tuesday, June 21, 2022 6:31 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 1 line · Xuejun

Hi Michal,

Hi Jun

Quoted 2 lines

Pls add your comments whenever you have a chance.

Sorry, I am confused, comments about what? Did I miss replay to my previous one? I didn't receive any replay to my question about why we need this spin lock when there is only check for filter.

Please resend it to me if You can.

Regards
Michal

Quoted 144 lines

Regards,

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Sunday, June 19, 2022 10:33 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 33 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62
++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using 
+VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in 

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3577

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16
+vlan) {
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 84 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +30 -0
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using 
+MAC addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in 
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const 
+u8
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure @@ -3651,7 +3693,15 @@ static 

int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +11 -1
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */ @@ -3660,6 
+3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) || @@ -3677,6 +3728,8 @@ 

static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -1
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#5 lore raw
Quoted 5 lines · Xuejun

Hi Michal,

Thanks for the reply.

The lock is access lock for both mac_filter_list & vlan_filter_list. Access to anyone of the two filter lists requires holding the lock per current code design.

Ok, thanks for explanation.

Quoted 170 lines

Regards

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Tuesday, June 21, 2022 6:31 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 1 line · Xuejun

Hi Michal,

Hi Jun

Quoted 2 lines

Pls add your comments whenever you have a chance.

Sorry, I am confused, comments about what? Did I miss replay to my previous one? I didn't receive any replay to my question about why we need this spin lock when there is only check for filter.

Please resend it to me if You can.

Regards
Michal

Quoted 144 lines

Regards,

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Sunday, June 19, 2022 10:33 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 33 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62
++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using 
+VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in 

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3577

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16
+vlan) {
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 84 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +30 -0
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using 
+MAC addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in 
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const 
+u8
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure @@ -3651,7 +3693,15 @@ static 

int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +11 -1
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */ @@ -3660,6 
+3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) || @@ -3677,6 +3728,8 @@ 

static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -1
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#6 lore raw
Quoted 8 lines · Michal Swiatkowski
Quoted 5 lines · Xuejun

Hi Michal,

Thanks for the reply.

The lock is access lock for both mac_filter_list & vlan_filter_list. Access to anyone of the two filter lists requires holding the lock per current code design.

Ok, thanks for explanation.

This doesn't explain why spin_lock_bh() is used and what contexts are being protected.

Quoted 171 lines
Quoted 171 lines

Regards

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Tuesday, June 21, 2022 6:31 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 1 line · Xuejun

Hi Michal,

Hi Jun

Quoted 2 lines

Pls add your comments whenever you have a chance.

Sorry, I am confused, comments about what? Did I miss replay to my previous one? I didn't receive any replay to my question about why we need this spin lock when there is only check for filter.

Please resend it to me if You can.

Regards
Michal

Quoted 144 lines

Regards,

Jun

-----Original Message-----
From: Michal Swiatkowski <[email protected]>
Sent: Sunday, June 19, 2022 10:33 PM
To: Zhang, Xuejun <[email protected]>
Cc: [email protected]; Kiran Patil <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

Quoted 33 lines · Jun Zhang

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62
++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +7 -0
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using 
+VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in 

drivers/net/ethernet/intel/iavf/iavf_main.c static int __iavf_setup_tc(struct net_device *netdev, void *type_data) · line 3577

Quoted 10 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +10 -0
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16
+vlan) {
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);

Why do we need lock here?

Quoted 84 lines
drivers/net/ethernet/intel/iavf/iavf_main.c +30 -0
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using 
+MAC addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in 
+VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const 
+u8
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure @@ -3651,7 +3693,15 @@ static 

int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +11 -1
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */ @@ -3660,6 
+3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))
 			if (is_valid_ether_addr(match.key->src) || @@ -3677,6 +3728,8 @@ 

static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -1
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#7 lore raw
In reply to Jun Zhang

Hi All,

This patch test is failing.
Please refer to the below HSD_ES for more details:
https://hsdes.intel.com/appstore/article/#/16017335057

Thanks,
Bharathi

Quoted 137 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jun Zhang
Sent: Friday, June 17, 2022 11:20 PM
To: [email protected]
Cc: Kiran Patil <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 ++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_main.c +52 -1
index 57c51a15bcbc..287c3e4bf8af 100644
@@ -3558,6 +3558,48 @@ static int __iavf_setup_tc(struct net_device
 *netdev, void *type_data)
 	return ret;
 }
 
+/**
+ * iavf_is_vlan_tc_filter_allowed - allowed to add tc-filter using VLAN
+ * @adapter: board private structure
+ * @vlan: VLAN to verify
+ *
+ * Using specified "vlan" ID, there must be active VLAN filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_vlan_tc_filter_allowed(struct iavf_adapter *adapter, u16 vlan)
+{
+	struct iavf_vlan_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_vlan(adapter, IAVF_VLAN(vlan, ETH_P_8021Q));
+	allowed = (f && f->add && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
+/**
+ * iavf_is_mac_tc_filter_allowed - allowed to add tc-filter using MAC
+addr
+ * @adapter: board private structure
+ * @macaddr: MAC address
+ *
+ * Using specified MAC address, there must be active MAC filter in VF's
+ * MAC-VLAN filter list.
+ */
+static bool
+iavf_is_mac_tc_filter_allowed(struct iavf_adapter *adapter, const u8
+*macaddr) {
+	struct iavf_mac_filter *f;
+	bool allowed;
+
+	spin_lock_bh(&adapter->mac_vlan_list_lock);
+	f = iavf_find_filter(adapter, macaddr);
+	allowed = (f && f->add && !f->is_new_mac && !f->remove);
+	spin_unlock_bh(&adapter->mac_vlan_list_lock);
+	return allowed;
+}
+
 /**
  * iavf_parse_cls_flower - Parse tc flower filters provided by kernel
  * @adapter: board private structure
@@ -3651,7 +3693,15 @@ static int iavf_parse_cls_flower(struct iavf_adapter
 *adapter,
 			}
 		}
 
-		if (!is_zero_ether_addr(match.key->dst))
+		if (!is_zero_ether_addr(match.key->dst)) {
+			if (!iavf_is_mac_tc_filter_allowed(adapter,
+							   match.key->dst)) {
+				dev_err(&adapter->pdev->dev,
+					"Dest MAC %pM doesn't belong to
 this VF\n",
+					match.mask->dst);
+				return -EINVAL;
+			}
+
 			if (is_valid_ether_addr(match.key->dst) ||
drivers/net/ethernet/intel/iavf/iavf_main.c +1 -0
 			    is_multicast_ether_addr(match.key->dst)) {
 				/* set the mask if a valid dst_mac address */
@@ -3660,6 +3710,7 @@ static int iavf_parse_cls_flower(struct iavf_adapter
 *adapter,
 				ether_addr_copy(vf->data.tcp_spec.dst_mac,
 						match.key->dst);
 			}
+		}
 
 		if (!is_zero_ether_addr(match.key->src))

if (is_valid_ether_addr(match.key->src) || @@ -
3677,6 +3728,8 @@ static int iavf_parse_cls_flower(struct iavf_adapter *adapter,

drivers/net/ethernet/intel/iavf/iavf_main.c +9 -0
 		flow_rule_match_vlan(rule, &match);
 		if (match.mask->vlan_id) {
+			u16 vlan = match.key->vlan_id & VLAN_VID_MASK;
+
 			if (match.mask->vlan_id == VLAN_VID_MASK) {
 				field_flags |= IAVF_CLOUD_FIELD_IVLAN;
 			} else {
@@ -3684,6 +3737,13 @@ static int iavf_parse_cls_flower(struct iavf_adapter
 *adapter,
 					match.mask->vlan_id);
 				return -EINVAL;
 			}
+
+			if (!iavf_is_vlan_tc_filter_allowed(adapter, vlan)) {
+				dev_err(&adapter->pdev->dev,
+					"VLAN %u doesn't belong to this
 VF\n",
+					vlan);
+				return -EINVAL;
+			}
 		}
drivers/net/ethernet/intel/iavf/iavf_main.c +0 -1
 		vf->mask.tcp_spec.vlan_id |= cpu_to_be16(0xffff);
 		vf->data.tcp_spec.vlan_id = cpu_to_be16(match.key->vlan_id);
--

2.35.3

Quoted 4 lines

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan

#8 lore raw
In reply to Jun Zhang
Quoted 19 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Jun Zhang
Sent: Friday, June 17, 2022 11:20 PM
To: [email protected]
Cc: Kiran Patil <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v1] iavf: validate dest MAC and VLAN from tc-filter code path

From: Kiran Patil <[email protected]>

Before allowing tc-filter using dest MAC, VLAN - check to make sure there is basic active filter using specified dest MAC and likewise for VLAN.

This check is must to allow only legit filter via tc-filter code path with or without ADQ.

Quoted 7 lines
Fixes 0075fa0fadd0 ("i40evf: Add support to apply cloud filters")
---
 drivers/net/ethernet/intel/iavf/iavf_main.c | 62 ++++++++++++++++++++-
 1 file changed, 61 insertions(+), 1 deletion(-)

The patch test is failing while adding a filter with MAC address on VF of a Fortville card.

#tc filter add dev ens803f0v0 protocol ip parent ffff: prio 1 flower ip_proto tcp dst_mac 6e:a5:60:1f:d6:54 dst_port 5555 skip_sw hw_tc 1 RTNETLINK answers: Invalid argument
We have an error talking to the kernel

Dmesg Error Log:
+20.796049] iavf 000:86:02.0: Dest MAC ff:ff:ff:ff:ff:ff:ff:ff doesn't belong to this VF

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan