]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: Allow to configure interface promiscuous mode
authorSusant Sahani <ssahani@vmware.com>
Tue, 15 Dec 2020 04:00:17 +0000 (05:00 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 15 Dec 2020 20:25:08 +0000 (20:25 +0000)
man/systemd.network.xml
src/network/networkd-link.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
test/fuzz/fuzz-network-parser/directives.network

index 27263c34ebb6fcba460e4904fb47cdad550c9efc..e5647f7dae3b93a7674651c68a763e6c05c94124 100644 (file)
           <para> For example, disabling ARP is useful when creating multiple MACVLAN or VLAN virtual
           interfaces atop a single lower-level physical interface, which will then only serve as a
           link/"bridge" device aggregating traffic to the same physical link and not participate in
-          the network otherwise.</para>
+          the network otherwise. Defaults to unset.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
         <term><varname>Multicast=</varname></term>
         <listitem>
-          <para>Takes a boolean. If set to true, the multicast flag on the device is enabled.</para>
+          <para>Takes a boolean. If set to true, the multicast flag on the device is enabled. Defaults to unset.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
         <term><varname>AllMulticast=</varname></term>
         <listitem>
           <para>Takes a boolean. If set to true, the driver retrieves all multicast packets from the network.
-          This happens when multicast routing is enabled.</para>
+          This happens when multicast routing is enabled. Defaults to unset.</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term><varname>Promiscuous=</varname></term>
+        <listitem>
+          <para>Takes a boolean. If set to true, promiscuous mode of the interface is enabled.
+          Defaults to unset.</para>
         </listitem>
       </varlistentry>
       <varlistentry>
index b7047c06d197cb5278599dcb739f6f5ccdfe6eec..7675f266e5ec609bf1bbb095a9cfe49a8304a6e5 100644 (file)
@@ -1108,7 +1108,8 @@ static int link_set_flags(Link *link) {
         if (!link->network)
                 return 0;
 
-        if (link->network->arp < 0 && link->network->multicast < 0 && link->network->allmulticast < 0)
+        if (link->network->arp < 0 && link->network->multicast < 0 && link->network->allmulticast < 0 &&
+            link->network->promiscuous < 0)
                 return 0;
 
         r = sd_rtnl_message_new_link(link->manager->rtnl, &req, RTM_SETLINK, link->ifindex);
@@ -1130,6 +1131,11 @@ static int link_set_flags(Link *link) {
                 SET_FLAG(ifi_flags, IFF_ALLMULTI, link->network->allmulticast);
         }
 
+        if (link->network->promiscuous >= 0) {
+                ifi_change |= IFF_PROMISC;
+                SET_FLAG(ifi_flags, IFF_PROMISC, link->network->promiscuous);
+        }
+
         r = sd_rtnl_message_link_set_flags(req, ifi_flags, ifi_change);
         if (r < 0)
                 return log_link_error_errno(link, r, "Could not set link flags: %m");
index 619c6a8c594c0da9a471e41a3174f02bb2f371f0..be7c076c619a32d9f2b502c738ab0c7dee8d9dac 100644 (file)
@@ -62,6 +62,7 @@ Link.Group,                                  config_parse_uint32,
 Link.ARP,                                    config_parse_tristate,                                    0,                             offsetof(Network, arp)
 Link.Multicast,                              config_parse_tristate,                                    0,                             offsetof(Network, multicast)
 Link.AllMulticast,                           config_parse_tristate,                                    0,                             offsetof(Network, allmulticast)
+Link.Promiscuous,                            config_parse_tristate,                                    0,                             offsetof(Network, promiscuous)
 Link.Unmanaged,                              config_parse_bool,                                        0,                             offsetof(Network, unmanaged)
 Link.RequiredForOnline,                      config_parse_required_for_online,                         0,                             0
 SR-IOV.VirtualFunction,                      config_parse_sr_iov_uint32,                               0,                             0
index 73c3788e278cee6eb7038f6c6c7a527db1352aa5..a5440a83c795c25efa90fccc9ee7d03c72b08cdb 100644 (file)
@@ -321,6 +321,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .arp = -1,
                 .multicast = -1,
                 .allmulticast = -1,
+                .promiscuous = -1,
 
                 .configure_without_carrier = false,
                 .ignore_carrier_loss = -1,
index 17e7d432c99076272b893b39c0be8537d743915a..a23de93126dbb47be6447d0d903e355f25daceda 100644 (file)
@@ -87,6 +87,7 @@ struct Network {
         int arp;
         int multicast;
         int allmulticast;
+        int promiscuous;
         bool unmanaged;
         bool required_for_online; /* Is this network required to be considered online? */
         LinkOperationalStateRange required_operstate_for_online;
index cb0c3205a0d3749da00814ed42800ff692cd8933..611d5bb7f7c397f7b540d7ad3342552161e3990f 100644 (file)
@@ -38,6 +38,7 @@ MTUBytes=
 Multicast=
 MACAddress=
 Group=
+Promiscuous=
 [SR-IOV]
 VirtualFunction=
 MACSpoofCheck=