Skip to content

Commit 39aa58d

Browse files
committed
networkd: Generate rule type, iif and oif in networkd configuration files
1 parent 69fe1e3 commit 39aa58d

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

src/networkd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,12 @@ write_ip_rule(NetplanIPRule* r, GString* s)
758758
g_string_append_printf(s, "FirewallMark=%d\n", r->fwmark);
759759
if (r->tos != NETPLAN_IP_RULE_TOS_UNSPEC)
760760
g_string_append_printf(s, "TypeOfService=%d\n", r->tos);
761+
if (r->type)
762+
g_string_append_printf(s, "Type=%s\n", r->type);
763+
if (r->iif)
764+
g_string_append_printf(s, "IncomingInterface=%s\n", r->iif);
765+
if (r->oif)
766+
g_string_append_printf(s, "OutgoingInterface=%s\n", r->oif);
761767
}
762768

763769
STATIC void

tests/generator/test_routing.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,75 @@ def test_ip_rule_tos(self):
654654
[RoutingPolicyRule]
655655
To=10.10.10.0/24
656656
TypeOfService=250
657+
'''})
658+
659+
def test_ip_rule_type(self):
660+
self.generate('''network:
661+
version: 2
662+
ethernets:
663+
engreen:
664+
addresses: ["192.168.14.2/24"]
665+
routing-policy:
666+
- to: 10.10.10.0/24
667+
type: blackhole
668+
''')
669+
670+
self.assert_networkd({'engreen.network': '''[Match]
671+
Name=engreen
672+
673+
[Network]
674+
LinkLocalAddressing=ipv6
675+
Address=192.168.14.2/24
676+
677+
[RoutingPolicyRule]
678+
To=10.10.10.0/24
679+
Type=blackhole
680+
'''})
681+
682+
def test_ip_rule_iif(self):
683+
self.generate('''network:
684+
version: 2
685+
ethernets:
686+
engreen:
687+
addresses: ["192.168.14.2/24"]
688+
routing-policy:
689+
- to: 10.10.10.0/24
690+
iif: engreen
691+
''')
692+
693+
self.assert_networkd({'engreen.network': '''[Match]
694+
Name=engreen
695+
696+
[Network]
697+
LinkLocalAddressing=ipv6
698+
Address=192.168.14.2/24
699+
700+
[RoutingPolicyRule]
701+
To=10.10.10.0/24
702+
IncomingInterface=engreen
703+
'''})
704+
705+
def test_ip_rule_oif(self):
706+
self.generate('''network:
707+
version: 2
708+
ethernets:
709+
engreen:
710+
addresses: ["192.168.14.2/24"]
711+
routing-policy:
712+
- to: 10.10.10.0/24
713+
oif: engreen
714+
''')
715+
716+
self.assert_networkd({'engreen.network': '''[Match]
717+
Name=engreen
718+
719+
[Network]
720+
LinkLocalAddressing=ipv6
721+
Address=192.168.14.2/24
722+
723+
[RoutingPolicyRule]
724+
To=10.10.10.0/24
725+
OutgoingInterface=engreen
657726
'''})
658727

659728
def test_use_routes(self):

0 commit comments

Comments
 (0)