[OpenWrt-Devel] [PATCH][netifd] Bridge hairpin mode must be off by default

Felix Fietkau nbd at openwrt.org
Thu Sep 10 09:37:35 EDT 2015


On 2015-09-10 15:00, Dmitry Ivanov wrote:
> Bridge hairpin mode must be off by default when multicast_to_unicast is
> off. Enabling this mode leads to broadcast frames such as ARP and DHCP
> being retransmitted back to AP in WDS configurations.
> 
> Signed-off-by: Dmitry Ivanov <dima at ubnt.com>
Please try this patch instead: 
---
diff --git a/device.h b/device.h
index b2c0ba9..37814c8 100644
--- a/device.h
+++ b/device.h
@@ -182,6 +182,7 @@ struct device {
 	bool iface_config;
 	bool default_config;
 	bool wireless;
+	bool wireless_ap;
 	bool wireless_isolate;
 
 	struct interface *config_iface;
diff --git a/system-linux.c b/system-linux.c
index 01500a5..f51c078 100644
--- a/system-linux.c
+++ b/system-linux.c
@@ -576,7 +576,7 @@ static char *system_get_bridge(const char *name, char *buf, int buflen)
 static void
 system_bridge_set_wireless(struct device *bridge, struct device *dev)
 {
-	bool mcast_to_ucast = true;
+	bool mcast_to_ucast = dev->wireless_ap;
 	bool hairpin = true;
 
 	if (bridge->settings.flags & DEV_OPT_MULTICAST_TO_UNICAST &&
diff --git a/wireless.c b/wireless.c
index d0d2942..7e8dc93 100644
--- a/wireless.c
+++ b/wireless.c
@@ -36,6 +36,7 @@ enum {
 	VIF_ATTR_DISABLED,
 	VIF_ATTR_NETWORK,
 	VIF_ATTR_ISOLATE,
+	VIF_ATTR_MODE,
 	__VIF_ATTR_MAX,
 };
 
@@ -43,6 +44,7 @@ static const struct blobmsg_policy vif_policy[__VIF_ATTR_MAX] = {
 	[VIF_ATTR_DISABLED] = { .name = "disabled", .type = BLOBMSG_TYPE_BOOL },
 	[VIF_ATTR_NETWORK] = { .name = "network", .type = BLOBMSG_TYPE_ARRAY },
 	[VIF_ATTR_ISOLATE] = { .name = "isolate", .type = BLOBMSG_TYPE_BOOL },
+	[VIF_ATTR_MODE] = { .name = "mode", .type = BLOBMSG_TYPE_STRING },
 };
 
 static const struct uci_blob_param_list vif_param = {
@@ -213,6 +215,7 @@ static void wireless_interface_handle_link(struct wireless_interface *vif, bool
 		if (dev) {
 			dev->wireless_isolate = vif->isolate;
 			dev->wireless = true;
+			dev->wireless_ap = vif->ap_mode;
 		}
 	}
 
@@ -714,6 +717,10 @@ void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *d
 	if (cur && blobmsg_get_bool(cur))
 		vif->isolate = blobmsg_get_bool(cur);
 
+	cur = tb[VIF_ATTR_MODE];
+	if (cur && !strcmp(blobmsg_get_string(cur), "ap"))
+		vif->ap_mode = true;
+
 	vlist_add(&wdev->interfaces, &vif->node, vif->name);
 }
 
diff --git a/wireless.h b/wireless.h
index 476c63e..cb725b2 100644
--- a/wireless.h
+++ b/wireless.h
@@ -78,6 +78,7 @@ struct wireless_interface {
 	const char *ifname;
 	struct blob_attr *network;
 	bool isolate;
+	bool ap_mode;
 };
 
 struct wireless_process {
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list