]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Merge pull request #13235 from yuwata/network-routing-policy-rule-family-13233
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 19 Aug 2019 08:08:23 +0000 (10:08 +0200)
committerGitHub <noreply@github.com>
Mon, 19 Aug 2019 08:08:23 +0000 (10:08 +0200)
network: add RoutingPolicyRule.Family= setting

1  2 
man/systemd.network.xml
test/test-network/systemd-networkd-tests.py

diff --combined man/systemd.network.xml
index 32589d34b191344babf5e91defbe1172656caa62,95c56b0ae3cabaceef1925fd2904fca34e23e52c..155c0868b207f11033ca7ea4ec9ff31b302d1124
@@@ -57,7 -57,7 +57,7 @@@
      <filename>/run/systemd/network</filename> directories. Drop-in files in
      <filename>/etc</filename> take precedence over those in <filename>/run</filename> which in turn
      take precedence over those in <filename>/usr/lib</filename>. Drop-in files under any of these
 -    directories take precedence over the main netdev file wherever located.</para>
 +    directories take precedence over the main network file wherever located.</para>
  
      <para>Note that an interface without any static IPv6 addresses configured, and neither DHCPv6
      nor IPv6LL enabled, shall be considered to have no IPv6 support. IPv6 will be automatically
@@@ -90,7 -90,7 +90,7 @@@
            <term><varname>MACAddress=</varname></term>
            <listitem>
              <para>A whitespace-separated list of hardware addresses. Use full colon-, hyphen- or dot-delimited hexadecimal. See the example below.
 -            This option may appear more than one, in which case the lists are merged. If the empty string is assigned to this option, the list
 +            This option may appear more than once, in which case the lists are merged. If the empty string is assigned to this option, the list
              of hardware addresses defined prior to this is reset.</para>
  
              <para>Example:
              <para>A boolean. Specifies whether the rule to be inverted. Defaults to false.</para>
            </listitem>
          </varlistentry>
+         <varlistentry>
+           <term><varname>Family=</varname></term>
+           <listitem>
+             <para>Takes a special value <literal>ipv4</literal>, <literal>ipv6</literal>, or
+             <literal>both</literal>. By default, the address family is determined by the address
+             specified in <varname>To=</varname> or <varname>From=</varname>. If neither
+             <varname>To=</varname> nor <varname>From=</varname> are specified, then defaults to
+             <literal>ipv4</literal>.</para>
+           </listitem>
+         </varlistentry>
        </variablelist>
    </refsect1>
  
index 59ae97167e77fcd72637dd0e9ac4c95b00756fbd,cde79817c8463a568895f9bc817faf84567293d9..8d123658a173bc4f1f643ebc4fb1006899500d0f
@@@ -1412,7 -1412,7 +1412,7 @@@ class NetworkdNetworkTests(unittest.Tes
          '24-keep-configuration-static.network',
          '24-search-domain.network',
          '25-address-link-section.network',
 -        '25-address-preferred-lifetime-zero-ipv6.network',
 +        '25-address-preferred-lifetime-zero.network',
          '25-address-static.network',
          '25-bind-carrier.network',
          '25-bond-active-backup-slave.netdev',
          'routing-policy-rule-dummy98.network',
          'routing-policy-rule-test1.network']
  
-     routing_policy_rule_tables = ['7', '8']
+     routing_policy_rule_tables = ['7', '8', '9']
      routes = [['blackhole', '202.54.1.2'], ['unreachable', '202.54.1.3'], ['prohibit', '202.54.1.4']]
  
      def setUp(self):
          self.assertRegex(output, 'inet6 fd[0-9a-f:]*1/64 scope global')
  
      def test_address_preferred_lifetime_zero_ipv6(self):
 -        copy_unit_to_networkd_unit_path('25-address-preferred-lifetime-zero-ipv6.network', '12-dummy.netdev')
 +        copy_unit_to_networkd_unit_path('25-address-preferred-lifetime-zero.network', '12-dummy.netdev')
          start_networkd(5)
  
 -        self.check_link_exists('dummy98')
 -        self.check_operstate('dummy98', 'routable', setup_state='configuring')
 +        self.wait_online(['dummy98:routable'])
  
          output = check_output('ip address show dummy98')
          print(output)
          self.assertRegex(output, 'inet 10.2.3.4/16 brd 10.2.255.255 scope link deprecated dummy98')
          self.assertRegex(output, 'inet6 2001:db8:0:f101::1/64 scope global')
  
 +        output = check_output('ip route show dev dummy98')
 +        print(output)
 +        self.assertRegex(output, 'default via 20.20.20.1 proto static')
 +
      def test_configure_without_carrier(self):
          copy_unit_to_networkd_unit_path('configure-without-carrier.network', '11-dummy.netdev')
          start_networkd()
          start_networkd()
          self.wait_online(['test1:degraded'])
  
-         output = check_output('ip rule')
+         output = check_output('ip rule list iif test1 priority 111')
          print(output)
-         self.assertRegex(output, '111')
+         self.assertRegex(output, '111:')
          self.assertRegex(output, 'from 192.168.100.18')
          self.assertRegex(output, r'tos (?:0x08|throughput)\s')
          self.assertRegex(output, 'iif test1')
          self.assertRegex(output, 'oif test1')
          self.assertRegex(output, 'lookup 7')
  
+         output = check_output('ip rule list iif test1 priority 101')
+         print(output)
+         self.assertRegex(output, '101:')
+         self.assertRegex(output, 'from all')
+         self.assertRegex(output, 'iif test1')
+         self.assertRegex(output, 'lookup 9')
+         output = check_output('ip -6 rule list iif test1 priority 100')
+         print(output)
+         self.assertRegex(output, '100:')
+         self.assertRegex(output, 'from all')
+         self.assertRegex(output, 'iif test1')
+         self.assertRegex(output, 'lookup 8')
+         output = check_output('ip -6 rule list iif test1 priority 101')
+         print(output)
+         self.assertRegex(output, '101:')
+         self.assertRegex(output, 'from all')
+         self.assertRegex(output, 'iif test1')
+         self.assertRegex(output, 'lookup 9')
      def test_routing_policy_rule_issue_11280(self):
          copy_unit_to_networkd_unit_path('routing-policy-rule-test1.network', '11-dummy.netdev',
                                          'routing-policy-rule-dummy98.network', '12-dummy.netdev')