mirror of
				https://github.com/Telecominfraproject/wlan-ap.git
				synced 2025-10-31 02:17:58 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			165 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
			
		
		
	
	
			165 lines
		
	
	
		
			5.5 KiB
		
	
	
	
		
			Diff
		
	
	
	
	
	
| From fc1417c4ba00a066c54fcb2a9bd0fbab096a4d7d Mon Sep 17 00:00:00 2001
 | |
| From: John Crispin <john@phrozen.org>
 | |
| Date: Mon, 19 Dec 2022 18:21:06 +0100
 | |
| Subject: [PATCH] netifd: allow disabling unicast_to_multicast conversion on
 | |
|  bridged wifi
 | |
| 
 | |
| Signed-off-by: John Crispin <john@phrozen.org>
 | |
| ---
 | |
|  ...port-for-disabling-multicast-to-unic.patch | 143 ++++++++++++++++++
 | |
|  1 file changed, 143 insertions(+)
 | |
|  create mode 100644 package/network/config/netifd/patches/0001-wireless-add-support-for-disabling-multicast-to-unic.patch
 | |
| 
 | |
| diff --git a/package/network/config/netifd/patches/0001-wireless-add-support-for-disabling-multicast-to-unic.patch b/package/network/config/netifd/patches/0001-wireless-add-support-for-disabling-multicast-to-unic.patch
 | |
| new file mode 100644
 | |
| index 0000000000..2dd03f0cb4
 | |
| --- /dev/null
 | |
| +++ b/package/network/config/netifd/patches/0001-wireless-add-support-for-disabling-multicast-to-unic.patch
 | |
| @@ -0,0 +1,143 @@
 | |
| +From a2e8cd75dbf6196f9408165e2e5f56c84fa37ca3 Mon Sep 17 00:00:00 2001
 | |
| +From: Felix Fietkau <nbd@nbd.name>
 | |
| +Date: Mon, 19 Dec 2022 18:15:01 +0100
 | |
| +Subject: [PATCH 1/2] wireless: add support for disabling multicast-to-unicast
 | |
| + per virtual interface
 | |
| +
 | |
| +Signed-off-by: Felix Fietkau <nbd@nbd.name>
 | |
| +---
 | |
| + system-linux.c |  6 ++++--
 | |
| + wireless.c     | 23 +++++++++++++++++++++++
 | |
| + wireless.h     |  2 ++
 | |
| + 3 files changed, 29 insertions(+), 2 deletions(-)
 | |
| +
 | |
| +diff --git a/system-linux.c b/system-linux.c
 | |
| +index 9fe869f..f16a955 100644
 | |
| +--- a/system-linux.c
 | |
| ++++ b/system-linux.c
 | |
| +@@ -847,8 +847,10 @@ system_bridge_set_wireless(struct device *bridge, struct device *dev)
 | |
| + 	bool mcast_to_ucast = dev->wireless_ap;
 | |
| + 	bool hairpin;
 | |
| + 
 | |
| +-	if (bridge->settings.flags & DEV_OPT_MULTICAST_TO_UNICAST &&
 | |
| +-	    !bridge->settings.multicast_to_unicast)
 | |
| ++	if (dev->settings.flags & DEV_OPT_MULTICAST_TO_UNICAST)
 | |
| ++		mcast_to_ucast = dev->settings.multicast_to_unicast;
 | |
| ++	else if (bridge->settings.flags & DEV_OPT_MULTICAST_TO_UNICAST &&
 | |
| ++	         !bridge->settings.multicast_to_unicast)
 | |
| + 		mcast_to_ucast = false;
 | |
| + 
 | |
| + 	hairpin = mcast_to_ucast || dev->wireless_proxyarp;
 | |
| +diff --git a/wireless.c b/wireless.c
 | |
| +index 118f5a7..705d6dd 100644
 | |
| +--- a/wireless.c
 | |
| ++++ b/wireless.c
 | |
| +@@ -65,6 +65,7 @@ enum {
 | |
| + 	VIF_ATTR_ISOLATE,
 | |
| + 	VIF_ATTR_MODE,
 | |
| + 	VIF_ATTR_PROXYARP,
 | |
| ++	VIF_ATTR_MCAST_TO_UCAST,
 | |
| + 	__VIF_ATTR_MAX,
 | |
| + };
 | |
| + 
 | |
| +@@ -74,6 +75,7 @@ static const struct blobmsg_policy vif_policy[__VIF_ATTR_MAX] = {
 | |
| + 	[VIF_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL },
 | |
| + 	[VIF_ATTR_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
 | |
| + 	[VIF_ATTR_PROXYARP] = { .name = "proxy_arp", .type = BLOBMSG_TYPE_BOOL },
 | |
| ++	[VIF_ATTR_MCAST_TO_UCAST] = { .name = "multicast_to_unicast", .type = BLOBMSG_TYPE_BOOL },
 | |
| + };
 | |
| + 
 | |
| + static const struct uci_blob_param_list vif_param = {
 | |
| +@@ -85,6 +87,7 @@ enum {
 | |
| + 	VLAN_ATTR_DISABLED,
 | |
| + 	VLAN_ATTR_NETWORK,
 | |
| + 	VLAN_ATTR_ISOLATE,
 | |
| ++	VLAN_ATTR_MCAST_TO_UCAST,
 | |
| + 	__VLAN_ATTR_MAX,
 | |
| + };
 | |
| + 
 | |
| +@@ -92,6 +95,7 @@ static const struct blobmsg_policy vlan_policy[__VLAN_ATTR_MAX] = {
 | |
| + 	[VLAN_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL },
 | |
| + 	[VLAN_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY },
 | |
| + 	[VLAN_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL },
 | |
| ++	[VLAN_ATTR_MCAST_TO_UCAST] = { .name = "multicast_to_unicast", .type = BLOBMSG_TYPE_BOOL },
 | |
| + };
 | |
| + 
 | |
| + static const struct uci_blob_param_list vlan_param = {
 | |
| +@@ -315,6 +319,17 @@ wireless_device_free_state(struct wireless_device *wdev)
 | |
| + 	}
 | |
| + }
 | |
| + 
 | |
| ++static void wireless_device_set_mcast_to_unicast(struct device *dev, int val)
 | |
| ++{
 | |
| ++	if (val < 0) {
 | |
| ++		dev->settings.flags &= ~DEV_OPT_MULTICAST_TO_UNICAST;
 | |
| ++		return;
 | |
| ++	}
 | |
| ++
 | |
| ++	dev->settings.multicast_to_unicast = !!val;
 | |
| ++	dev->settings.flags |= DEV_OPT_MULTICAST_TO_UNICAST;
 | |
| ++}
 | |
| ++
 | |
| + static void wireless_interface_handle_link(struct wireless_interface *vif, const char *ifname, bool up)
 | |
| + {
 | |
| + 	struct interface *iface;
 | |
| +@@ -336,6 +351,7 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, const
 | |
| + 			dev->wireless_proxyarp = vif->proxyarp;
 | |
| + 			dev->wireless = true;
 | |
| + 			dev->wireless_ap = vif->ap_mode;
 | |
| ++			wireless_device_set_mcast_to_unicast(dev, vif->multicast_to_unicast);
 | |
| + 			dev->bpdu_filter = dev->wireless_ap;
 | |
| + 		}
 | |
| + 	}
 | |
| +@@ -368,6 +384,7 @@ static void wireless_vlan_handle_link(struct wireless_vlan *vlan, bool up)
 | |
| + 			dev->wireless = true;
 | |
| + 			dev->wireless_ap = true;
 | |
| + 			dev->bpdu_filter = true;
 | |
| ++			wireless_device_set_mcast_to_unicast(dev, vlan->multicast_to_unicast);
 | |
| + 		}
 | |
| + 	}
 | |
| + 
 | |
| +@@ -811,6 +828,9 @@ wireless_interface_init_config(struct wireless_interface *vif)
 | |
| + 
 | |
| + 	cur = tb[VIF_ATTR_PROXYARP];
 | |
| + 	vif->proxyarp = vif->ap_mode && cur && blobmsg_get_bool(cur);
 | |
| ++
 | |
| ++	cur = tb[VIF_ATTR_MCAST_TO_UCAST];
 | |
| ++	vif->multicast_to_unicast = cur ? blobmsg_get_bool(cur) : -1;
 | |
| + }
 | |
| + 
 | |
| + /* vlist update call for wireless interface list */
 | |
| +@@ -873,6 +893,9 @@ wireless_vlan_init_config(struct wireless_vlan *vlan)
 | |
| + 	cur = tb[VLAN_ATTR_ISOLATE];
 | |
| + 	if (cur)
 | |
| + 		vlan->isolate = blobmsg_get_bool(cur);
 | |
| ++
 | |
| ++	cur = tb[VLAN_ATTR_MCAST_TO_UCAST];
 | |
| ++	vlan->multicast_to_unicast = cur ? blobmsg_get_bool(cur) : -1;
 | |
| + }
 | |
| + 
 | |
| + /* vlist update call for vlan list */
 | |
| +diff --git a/wireless.h b/wireless.h
 | |
| +index 7b87611..690c797 100644
 | |
| +--- a/wireless.h
 | |
| ++++ b/wireless.h
 | |
| +@@ -91,6 +91,7 @@ struct wireless_interface {
 | |
| + 	bool proxyarp;
 | |
| + 	bool isolate;
 | |
| + 	bool ap_mode;
 | |
| ++	int multicast_to_unicast;
 | |
| + };
 | |
| + 
 | |
| + struct wireless_vlan {
 | |
| +@@ -106,6 +107,7 @@ struct wireless_vlan {
 | |
| + 
 | |
| + 	const char *ifname;
 | |
| + 	struct blob_attr *network;
 | |
| ++	int multicast_to_unicast;
 | |
| + 	bool isolate;
 | |
| + };
 | |
| + 
 | |
| +-- 
 | |
| +2.25.1
 | |
| +
 | |
| -- 
 | |
| 2.25.1
 | |
| 
 | 
