diff options
author | Thomas Haller <thaller@redhat.com> | 2019-03-23 15:09:29 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2019-03-25 22:54:10 +0100 |
commit | aaceb4e2c4afb4374c2dc46468e0e4c832565db3 (patch) | |
tree | 3663e03d5c7966bbd11ad924b0da8c341a217ede /src/NetworkManagerUtils.c | |
parent | f5a238a1d1ba141e8c04902e25bfad312abf4b3b (diff) | |
download | NetworkManager-th/routing-rule-pt2.tar.gz |
core: add handling of IP routing rules to NMDeviceth/routing-rule-pt2
Diffstat (limited to 'src/NetworkManagerUtils.c')
-rw-r--r-- | src/NetworkManagerUtils.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index 71bfbf7c10..0f63239129 100644 --- a/src/NetworkManagerUtils.c +++ b/src/NetworkManagerUtils.c @@ -23,6 +23,8 @@ #include "NetworkManagerUtils.h" +#include <linux/fib_rules.h> + #include "nm-utils/nm-c-list.h" #include "nm-common-macros.h" @@ -908,6 +910,48 @@ nm_match_spec_device_by_pllink (const NMPlatformLink *pllink, /*****************************************************************************/ +NMPlatformRoutingRule * +nm_ip_routing_rule_to_platform (const NMIPRoutingRule *rule, + NMPlatformRoutingRule *out_pl) +{ + nm_assert (rule); + nm_assert (nm_ip_routing_rule_validate (rule, NULL)); + nm_assert (out_pl); + + *out_pl = (NMPlatformRoutingRule) { + .addr_family = nm_ip_routing_rule_get_addr_family (rule), + .flags = ( nm_ip_routing_rule_get_invert (rule) + ? FIB_RULE_INVERT + : 0), + .priority = nm_ip_routing_rule_get_priority (rule), + .tos = nm_ip_routing_rule_get_tos (rule), + .ip_proto = nm_ip_routing_rule_get_ipproto (rule), + .fwmark = nm_ip_routing_rule_get_fwmark (rule), + .fwmask = nm_ip_routing_rule_get_fwmask (rule), + .sport_range = { + .start = nm_ip_routing_rule_get_source_port_start (rule), + .end = nm_ip_routing_rule_get_source_port_end (rule), + }, + .dport_range = { + .start = nm_ip_routing_rule_get_destination_port_start (rule), + .end = nm_ip_routing_rule_get_destination_port_end (rule), + }, + .src = *(nm_ip_routing_rule_get_from_bin (rule) ?: &nm_ip_addr_zero), + .dst = *(nm_ip_routing_rule_get_to_bin (rule) ?: &nm_ip_addr_zero), + .src_len = nm_ip_routing_rule_get_from_len (rule), + .dst_len = nm_ip_routing_rule_get_to_len (rule), + .action = nm_ip_routing_rule_get_action (rule), + .table = nm_ip_routing_rule_get_table (rule), + }; + + nm_ip_routing_rule_get_xifname_bin (rule, TRUE, out_pl->iifname); + nm_ip_routing_rule_get_xifname_bin (rule, FALSE, out_pl->oifname); + + return out_pl; +} + +/*****************************************************************************/ + struct _NMShutdownWaitObjHandle { CList lst; GObject *watched_obj; |