network: add support to configure proxy ARP/WIFI

This commit is contained in:
Susant Sahani 2019-05-09 02:32:12 +02:00 committed by Yu Watanabe
parent 9aa5d8ba84
commit 0fadb2a46f
6 changed files with 48 additions and 0 deletions

View file

@ -1908,6 +1908,17 @@
When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>MulticastRouter=</varname></term>
<listitem>
<para>Configures this port for having multicast routers attached. A port with a multicast
router will receive all multicast traffic. Takes one of <literal>no</literal>
to disable multicast routers on this port, <literal>query</literal> to let the system detect
the presence of routers, <literal>permanent</literal> to permanently enable multicast traffic
forwarding on this port, or <literal>temporary</literal> to enable multicast routers temporarily
on this port, not depending on incoming queries. When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>Cost=</varname></term>
<listitem>

View file

@ -1648,6 +1648,12 @@ static int link_set_bridge(Link *link) {
return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_PRIORITY attribute: %m");
}
if (link->network->multicast_router != _MULTICAST_ROUTER_INVALID) {
r = sd_netlink_message_append_u8(req, IFLA_BRPORT_MULTICAST_ROUTER, link->network->multicast_router);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFLA_BRPORT_MULTICAST_ROUTER attribute: %m");
}
r = sd_netlink_message_close_container(req);
if (r < 0)
return log_link_error_errno(link, r, "Could not append IFLA_LINKINFO attribute: %m");

View file

@ -180,6 +180,7 @@ Bridge.Learning, config_parse_tristate,
Bridge.ProxyARP, config_parse_tristate, 0, offsetof(Network, bridge_proxy_arp)
Bridge.ProxyARPWiFi, config_parse_tristate, 0, offsetof(Network, bridge_proxy_arp_wifi)
Bridge.Priority, config_parse_bridge_port_priority, 0, offsetof(Network, priority)
Bridge.MulticastRouter, config_parse_multicast_router, 0, offsetof(Network, multicast_router)
BridgeFDB.MACAddress, config_parse_fdb_hwaddr, 0, 0
BridgeFDB.VLANId, config_parse_fdb_vlan_id, 0, 0
BridgeFDB.Destination, config_parse_fdb_destination, 0, 0

View file

@ -391,6 +391,7 @@ int network_load_one(Manager *manager, const char *filename) {
.bridge_proxy_arp = -1,
.bridge_proxy_arp_wifi = -1,
.priority = LINK_BRIDGE_PORT_PRIORITY_INVALID,
.multicast_router = _MULTICAST_ROUTER_INVALID,
.lldp_mode = LLDP_MODE_ROUTERS_ONLY,
@ -1723,3 +1724,14 @@ int config_parse_required_for_online(
return 0;
}
static const char* const multicast_router_table[_MULTICAST_ROUTER_MAX] = {
[MULTICAST_ROUTER_NONE] = "no",
[MULTICAST_ROUTER_TEMPORARY_QUERY] = "query",
[MULTICAST_ROUTER_PERMANENT] = "permanent",
[MULTICAST_ROUTER_TEMPORARY] = "temporary",
};
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(multicast_router, MulticastRouter, _MULTICAST_ROUTER_INVALID);
DEFINE_CONFIG_PARSE_ENUM(config_parse_multicast_router, multicast_router, MulticastRouter,
"Failed to parse bridge multicast router setting");

View file

@ -1,6 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1+ */
#pragma once
#include <netinet/in.h>
#include <linux/if_bridge.h>
#include "sd-bus.h"
#include "sd-device.h"
@ -84,6 +87,15 @@ typedef enum RADVPrefixDelegation {
_RADV_PREFIX_DELEGATION_INVALID = -1,
} RADVPrefixDelegation;
typedef enum MulticastRouter {
MULTICAST_ROUTER_NONE = MDB_RTR_TYPE_DISABLED,
MULTICAST_ROUTER_TEMPORARY_QUERY = MDB_RTR_TYPE_TEMP_QUERY,
MULTICAST_ROUTER_PERMANENT = MDB_RTR_TYPE_PERM,
MULTICAST_ROUTER_TEMPORARY = MDB_RTR_TYPE_TEMP,
_MULTICAST_ROUTER_MAX,
_MULTICAST_ROUTER_INVALID = -1,
} MulticastRouter;
typedef struct Manager Manager;
struct Network {
@ -185,6 +197,7 @@ struct Network {
int bridge_proxy_arp_wifi;
uint32_t cost;
uint16_t priority;
MulticastRouter multicast_router;
bool use_br_vlan;
uint16_t pvid;
@ -319,6 +332,7 @@ CONFIG_PARSER_PROTOTYPE(config_parse_ntp);
CONFIG_PARSER_PROTOTYPE(config_parse_iaid);
CONFIG_PARSER_PROTOTYPE(config_parse_required_for_online);
CONFIG_PARSER_PROTOTYPE(config_parse_dhcp_max_attempts);
CONFIG_PARSER_PROTOTYPE(config_parse_multicast_router);
/* Legacy IPv4LL support */
CONFIG_PARSER_PROTOTYPE(config_parse_ipv4ll);
@ -340,3 +354,6 @@ LLDPMode lldp_mode_from_string(const char *s) _pure_;
const char* radv_prefix_delegation_to_string(RADVPrefixDelegation i) _const_;
RADVPrefixDelegation radv_prefix_delegation_from_string(const char *s) _pure_;
const char* multicast_router_to_string(MulticastRouter i) _const_;
MulticastRouter multicast_router_from_string(const char *s) _pure_;

View file

@ -12,6 +12,7 @@ NeighborSuppression=
Learning=
ProxyARP=
ProxyARPWiFi=
MulticastRouter=
[Match]
KernelVersion=
Type=