developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 1 | --- a/src/ap/ap_config.h |
| 2 | +++ b/src/ap/ap_config.h |
| 3 | @@ -284,6 +284,7 @@ struct hostapd_bss_config { |
| 4 | char iface[IFNAMSIZ + 1]; |
| 5 | char bridge[IFNAMSIZ + 1]; |
| 6 | char ft_iface[IFNAMSIZ + 1]; |
| 7 | + char snoop_iface[IFNAMSIZ + 1]; |
| 8 | char vlan_bridge[IFNAMSIZ + 1]; |
| 9 | char wds_bridge[IFNAMSIZ + 1]; |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 10 | int bridge_hairpin; /* hairpin_mode on bridge members */ |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 11 | --- a/src/ap/x_snoop.c |
| 12 | +++ b/src/ap/x_snoop.c |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 13 | @@ -33,28 +33,31 @@ int x_snoop_init(struct hostapd_data *ha |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 14 | |
| 15 | hapd->x_snoop_initialized = true; |
| 16 | |
| 17 | - if (hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, |
| 18 | + if (!conf->snoop_iface[0] && |
| 19 | + hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, |
| 20 | 1)) { |
| 21 | wpa_printf(MSG_DEBUG, |
| 22 | "x_snoop: Failed to enable hairpin_mode on the bridge port"); |
| 23 | return -1; |
| 24 | } |
| 25 | |
| 26 | - if (hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_PROXYARP, 1)) { |
| 27 | + if (!conf->snoop_iface[0] && |
| 28 | + hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_PROXYARP, 1)) { |
| 29 | wpa_printf(MSG_DEBUG, |
| 30 | "x_snoop: Failed to enable proxyarp on the bridge port"); |
| 31 | return -1; |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 32 | } |
| 33 | |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 34 | if (hostapd_drv_br_set_net_param(hapd, DRV_BR_NET_PARAM_GARP_ACCEPT, |
| 35 | - 1)) { |
| 36 | + conf->snoop_iface[0] ? conf->snoop_iface : NULL, 1)) { |
| 37 | wpa_printf(MSG_DEBUG, |
| 38 | "x_snoop: Failed to enable accepting gratuitous ARP on the bridge"); |
| 39 | return -1; |
| 40 | } |
| 41 | |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 42 | #ifdef CONFIG_IPV6 |
| 43 | - if (hostapd_drv_br_set_net_param(hapd, DRV_BR_MULTICAST_SNOOPING, 1)) { |
| 44 | + if (!conf->snoop_iface[0] && |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 45 | + hostapd_drv_br_set_net_param(hapd, DRV_BR_MULTICAST_SNOOPING, NULL, 1)) { |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 46 | wpa_printf(MSG_DEBUG, |
| 47 | "x_snoop: Failed to enable multicast snooping on the bridge"); |
| 48 | return -1; |
| 49 | @@ -73,8 +76,12 @@ x_snoop_get_l2_packet(struct hostapd_dat |
| 50 | { |
| 51 | struct hostapd_bss_config *conf = hapd->conf; |
| 52 | struct l2_packet_data *l2; |
| 53 | + const char *ifname = conf->bridge; |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 54 | + |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 55 | + if (conf->snoop_iface[0]) |
| 56 | + ifname = conf->snoop_iface; |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 57 | |
| 58 | - l2 = l2_packet_init(conf->bridge, NULL, ETH_P_ALL, handler, hapd, 1); |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 59 | + l2 = l2_packet_init(ifname, NULL, ETH_P_ALL, handler, hapd, 1); |
| 60 | if (l2 == NULL) { |
| 61 | wpa_printf(MSG_DEBUG, |
| 62 | "x_snoop: Failed to initialize L2 packet processing %s", |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 63 | @@ -127,9 +134,12 @@ void x_snoop_mcast_to_ucast_convert_send |
| 64 | |
| 65 | void x_snoop_deinit(struct hostapd_data *hapd) |
| 66 | { |
| 67 | + struct hostapd_bss_config *conf = hapd->conf; |
| 68 | + |
| 69 | if (!hapd->x_snoop_initialized) |
| 70 | return; |
| 71 | - hostapd_drv_br_set_net_param(hapd, DRV_BR_NET_PARAM_GARP_ACCEPT, 0); |
| 72 | + hostapd_drv_br_set_net_param(hapd, DRV_BR_NET_PARAM_GARP_ACCEPT, |
| 73 | + conf->snoop_iface[0] ? conf->snoop_iface : NULL, 0); |
| 74 | hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_PROXYARP, 0); |
| 75 | hostapd_drv_br_port_set_attr(hapd, DRV_BR_PORT_ATTR_HAIRPIN_MODE, 0); |
| 76 | hapd->x_snoop_initialized = false; |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 77 | --- a/hostapd/config_file.c |
| 78 | +++ b/hostapd/config_file.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 79 | @@ -2322,6 +2322,8 @@ static int hostapd_config_fill(struct ho |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 80 | os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge)); |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 81 | } else if (os_strcmp(buf, "bridge_hairpin") == 0) { |
| 82 | bss->bridge_hairpin = atoi(pos); |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 83 | + } else if (os_strcmp(buf, "snoop_iface") == 0) { |
| 84 | + os_strlcpy(bss->snoop_iface, pos, sizeof(bss->snoop_iface)); |
| 85 | } else if (os_strcmp(buf, "vlan_bridge") == 0) { |
| 86 | os_strlcpy(bss->vlan_bridge, pos, sizeof(bss->vlan_bridge)); |
| 87 | } else if (os_strcmp(buf, "wds_bridge") == 0) { |
developer | 95671ae | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 88 | --- a/src/ap/ap_drv_ops.h |
| 89 | +++ b/src/ap/ap_drv_ops.h |
| 90 | @@ -366,12 +366,12 @@ static inline int hostapd_drv_br_port_se |
| 91 | |
| 92 | static inline int hostapd_drv_br_set_net_param(struct hostapd_data *hapd, |
| 93 | enum drv_br_net_param param, |
| 94 | - unsigned int val) |
| 95 | + const char *ifname, unsigned int val) |
| 96 | { |
| 97 | if (hapd->driver == NULL || hapd->drv_priv == NULL || |
| 98 | hapd->driver->br_set_net_param == NULL) |
| 99 | return -1; |
| 100 | - return hapd->driver->br_set_net_param(hapd->drv_priv, param, val); |
| 101 | + return hapd->driver->br_set_net_param(hapd->drv_priv, param, ifname, val); |
| 102 | } |
| 103 | |
| 104 | static inline int hostapd_drv_vendor_cmd(struct hostapd_data *hapd, |
| 105 | --- a/src/drivers/driver.h |
| 106 | +++ b/src/drivers/driver.h |
| 107 | @@ -4209,7 +4209,7 @@ struct wpa_driver_ops { |
| 108 | * Returns: 0 on success, negative (<0) on failure |
| 109 | */ |
| 110 | int (*br_set_net_param)(void *priv, enum drv_br_net_param param, |
| 111 | - unsigned int val); |
| 112 | + const char *ifname, unsigned int val); |
| 113 | |
| 114 | /** |
| 115 | * get_wowlan - Get wake-on-wireless status |
| 116 | --- a/src/drivers/driver_nl80211.c |
| 117 | +++ b/src/drivers/driver_nl80211.c |
| 118 | @@ -12168,7 +12168,7 @@ static const char * drv_br_net_param_str |
| 119 | |
| 120 | |
| 121 | static int wpa_driver_br_set_net_param(void *priv, enum drv_br_net_param param, |
| 122 | - unsigned int val) |
| 123 | + const char *ifname, unsigned int val) |
| 124 | { |
| 125 | struct i802_bss *bss = priv; |
| 126 | char path[128]; |
| 127 | @@ -12194,8 +12194,11 @@ static int wpa_driver_br_set_net_param(v |
| 128 | return -EINVAL; |
| 129 | } |
| 130 | |
| 131 | + if (!ifname) |
| 132 | + ifname = bss->brname; |
| 133 | + |
| 134 | os_snprintf(path, sizeof(path), "/proc/sys/net/ipv%d/conf/%s/%s", |
| 135 | - ip_version, bss->brname, param_txt); |
| 136 | + ip_version, ifname, param_txt); |
| 137 | |
| 138 | set_val: |
| 139 | if (linux_write_system_file(path, val)) |