libnm: add NMIPRoutingRule API
Add NMIPRoutingRule API with a few basic rule properties. More properties will be added later as we want to support them. Also, add to/from functions for string/GVariant representations. These will be needed to persist/load/exchange rules. The to-string format follows the `ip rule add` syntax, with the aim to be partially compatible. Full compatibility is not possible though, for various reasons (see code comment).
This commit is contained in:
@@ -613,6 +613,47 @@ void _nm_wireguard_peer_set_public_key_bin (NMWireGuardPeer *self,
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
const NMIPAddr *nm_ip_routing_rule_get_from_bin (const NMIPRoutingRule *self);
|
||||||
|
void nm_ip_routing_rule_set_from_bin (NMIPRoutingRule *self,
|
||||||
|
gconstpointer from,
|
||||||
|
guint8 len);
|
||||||
|
|
||||||
|
const NMIPAddr *nm_ip_routing_rule_get_to_bin (const NMIPRoutingRule *self);
|
||||||
|
void nm_ip_routing_rule_set_to_bin (NMIPRoutingRule *self,
|
||||||
|
gconstpointer to,
|
||||||
|
guint8 len);
|
||||||
|
|
||||||
|
gboolean nm_ip_routing_rule_get_xifname_bin (const NMIPRoutingRule *self,
|
||||||
|
gboolean iif /* or else oif */,
|
||||||
|
char out_xifname[static 16]);
|
||||||
|
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_ACTION "action"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_DPORT_END "dport-end"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_DPORT_START "dport-start"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_FAMILY "family"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_FROM "from"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_FROM_LEN "from-len"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_FWMARK "fwmark"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_FWMASK "fwmask"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_IIFNAME "iifname"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_INVERT "invert"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_IPPROTO "ipproto"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_OIFNAME "oifname"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_PRIORITY "priority"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_SPORT_END "sport-end"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_SPORT_START "sport-start"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_TABLE "table"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_TO "to"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_TOS "tos"
|
||||||
|
#define NM_IP_ROUTING_RULE_ATTR_TO_LEN "to-len"
|
||||||
|
|
||||||
|
NMIPRoutingRule *nm_ip_routing_rule_from_dbus (GVariant *variant,
|
||||||
|
gboolean strict,
|
||||||
|
GError **error);
|
||||||
|
GVariant *nm_ip_routing_rule_to_dbus (const NMIPRoutingRule *self);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
typedef struct _NMSettInfoSetting NMSettInfoSetting;
|
typedef struct _NMSettInfoSetting NMSettInfoSetting;
|
||||||
typedef struct _NMSettInfoProperty NMSettInfoProperty;
|
typedef struct _NMSettInfoProperty NMSettInfoProperty;
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -159,6 +159,153 @@ gboolean nm_ip_route_attribute_validate (const char *name,
|
|||||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND "lock-initrwnd"
|
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_INITRWND "lock-initrwnd"
|
||||||
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU "lock-mtu"
|
#define NM_IP_ROUTE_ATTRIBUTE_LOCK_MTU "lock-mtu"
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
typedef struct NMIPRoutingRule NMIPRoutingRule;
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
GType nm_ip_routing_rule_get_type (void);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
NMIPRoutingRule *nm_ip_routing_rule_new (int addr_family);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
NMIPRoutingRule *nm_ip_routing_rule_new_clone (const NMIPRoutingRule *rule);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
NMIPRoutingRule *nm_ip_routing_rule_ref (NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_unref (NMIPRoutingRule *self);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
gboolean nm_ip_routing_rule_is_sealed (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_seal (NMIPRoutingRule *self);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
int nm_ip_routing_rule_get_addr_family (const NMIPRoutingRule *self);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
gboolean nm_ip_routing_rule_get_invert (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_invert (NMIPRoutingRule *self, gboolean invert);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
gint64 nm_ip_routing_rule_get_priority (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_priority (NMIPRoutingRule *self, gint64 priority);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint8 nm_ip_routing_rule_get_tos (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_tos (NMIPRoutingRule *self, guint8 tos);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint8 nm_ip_routing_rule_get_ipproto (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_ipproto (NMIPRoutingRule *self, guint8 ipproto);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint16 nm_ip_routing_rule_get_source_port_start (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint16 nm_ip_routing_rule_get_source_port_end (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_source_port (NMIPRoutingRule *self, guint16 start, guint16 end);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint16 nm_ip_routing_rule_get_destination_port_start (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint16 nm_ip_routing_rule_get_destination_port_end (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_destination_port (NMIPRoutingRule *self, guint16 start, guint16 end);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint32 nm_ip_routing_rule_get_fwmark (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint32 nm_ip_routing_rule_get_fwmask (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_fwmark (NMIPRoutingRule *self, guint32 fwmark, guint32 fwmask);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint8 nm_ip_routing_rule_get_from_len (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
const char *nm_ip_routing_rule_get_from (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_from (NMIPRoutingRule *self,
|
||||||
|
const char *from,
|
||||||
|
guint8 len);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint8 nm_ip_routing_rule_get_to_len (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
const char *nm_ip_routing_rule_get_to (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_to (NMIPRoutingRule *self,
|
||||||
|
const char *to,
|
||||||
|
guint8 len);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
const char *nm_ip_routing_rule_get_iifname (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_iifname (NMIPRoutingRule *self, const char *iifname);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
const char *nm_ip_routing_rule_get_oifname (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_oifname (NMIPRoutingRule *self, const char *oifname);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint8 nm_ip_routing_rule_get_action (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_action (NMIPRoutingRule *self, guint8 action);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
guint32 nm_ip_routing_rule_get_table (const NMIPRoutingRule *self);
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
void nm_ip_routing_rule_set_table (NMIPRoutingRule *self, guint32 table);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
int nm_ip_routing_rule_cmp (const NMIPRoutingRule *rule,
|
||||||
|
const NMIPRoutingRule *other);
|
||||||
|
|
||||||
|
NM_AVAILABLE_IN_1_18
|
||||||
|
gboolean nm_ip_routing_rule_validate (const NMIPRoutingRule *self,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* NMIPRoutingRuleAsStringFlags:
|
||||||
|
* @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE: no flags selected.
|
||||||
|
* @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET: whether to allow parsing
|
||||||
|
* IPv4 addresses.
|
||||||
|
* @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6: whether to allow parsing
|
||||||
|
* IPv6 addresses. If both @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET and
|
||||||
|
* @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6 are unset, it's the same
|
||||||
|
* as setting them both.
|
||||||
|
* @NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE: if set, ensure that the
|
||||||
|
* rule verfies or fail.
|
||||||
|
*
|
||||||
|
* Since: 1.18
|
||||||
|
*/
|
||||||
|
typedef enum { /*< flags >*/
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE = 0,
|
||||||
|
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET = 0x1,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6 = 0x2,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE = 0x4,
|
||||||
|
} NMIPRoutingRuleAsStringFlags;
|
||||||
|
|
||||||
|
NMIPRoutingRule *nm_ip_routing_rule_from_string (const char *str,
|
||||||
|
NMIPRoutingRuleAsStringFlags to_string_flags,
|
||||||
|
GHashTable *extra_args,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
char *nm_ip_routing_rule_to_string (const NMIPRoutingRule *self,
|
||||||
|
NMIPRoutingRuleAsStringFlags to_string_flags,
|
||||||
|
GHashTable *extra_args,
|
||||||
|
GError **error);
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define NM_TYPE_SETTING_IP_CONFIG (nm_setting_ip_config_get_type ())
|
#define NM_TYPE_SETTING_IP_CONFIG (nm_setting_ip_config_get_type ())
|
||||||
#define NM_SETTING_IP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP_CONFIG, NMSettingIPConfig))
|
#define NM_SETTING_IP_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_SETTING_IP_CONFIG, NMSettingIPConfig))
|
||||||
#define NM_SETTING_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IPCONFIG, NMSettingIPConfigClass))
|
#define NM_SETTING_IP_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_SETTING_IPCONFIG, NMSettingIPConfigClass))
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "nm-default.h"
|
#include "nm-default.h"
|
||||||
|
|
||||||
#include <linux/pkt_sched.h>
|
#include <linux/pkt_sched.h>
|
||||||
|
#include <net/if.h>
|
||||||
|
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-utils-private.h"
|
#include "nm-utils-private.h"
|
||||||
@@ -2675,6 +2676,203 @@ test_roundtrip_conversion (gconstpointer test_data)
|
|||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
static NMIPRoutingRule *
|
||||||
|
_rr_from_str_get_impl (const char *str, const char *const*aliases)
|
||||||
|
{
|
||||||
|
nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr = NULL;
|
||||||
|
gs_free_error GError *error = NULL;
|
||||||
|
gboolean vbool;
|
||||||
|
int addr_family;
|
||||||
|
int i;
|
||||||
|
NMIPRoutingRuleAsStringFlags to_string_flags;
|
||||||
|
|
||||||
|
rr = nm_ip_routing_rule_from_string (str,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE,
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (rr, error);
|
||||||
|
|
||||||
|
addr_family = nm_ip_routing_rule_get_addr_family (rr);
|
||||||
|
g_assert (NM_IN_SET (addr_family, AF_INET, AF_INET6));
|
||||||
|
|
||||||
|
if (addr_family == AF_INET)
|
||||||
|
to_string_flags = NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET;
|
||||||
|
else
|
||||||
|
to_string_flags = NM_IP_ROUTING_RULE_AS_STRING_FLAGS_AF_INET6;
|
||||||
|
|
||||||
|
for (i = 0; TRUE; i++) {
|
||||||
|
nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr2 = NULL;
|
||||||
|
gs_free char *str1 = NULL;
|
||||||
|
gs_unref_variant GVariant *variant1 = NULL;
|
||||||
|
const char *cstr1;
|
||||||
|
|
||||||
|
switch (i) {
|
||||||
|
case 0:
|
||||||
|
rr2 = nm_ip_routing_rule_ref (rr);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 1:
|
||||||
|
rr2 = nm_ip_routing_rule_from_string (str,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE
|
||||||
|
| (nmtst_get_rand_bool () ? to_string_flags : NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE),
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (rr, error);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
str1 = nm_ip_routing_rule_to_string (rr,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE
|
||||||
|
| (nmtst_get_rand_bool () ? to_string_flags : NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE),
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (str1 && str1[0], error);
|
||||||
|
|
||||||
|
g_assert_cmpstr (str, ==, str1);
|
||||||
|
|
||||||
|
rr2 = nm_ip_routing_rule_from_string (str1,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE
|
||||||
|
| (nmtst_get_rand_bool () ? to_string_flags : NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE),
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (rr, error);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
variant1 = nm_ip_routing_rule_to_dbus (rr);
|
||||||
|
g_assert (variant1);
|
||||||
|
g_assert (g_variant_is_floating (variant1));
|
||||||
|
g_assert (g_variant_is_of_type (variant1, G_VARIANT_TYPE_VARDICT));
|
||||||
|
|
||||||
|
rr2 = nm_ip_routing_rule_from_dbus (variant1,
|
||||||
|
TRUE,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (rr, error);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (!aliases || !aliases[0])
|
||||||
|
goto done;
|
||||||
|
cstr1 = (aliases++)[0];
|
||||||
|
rr2 = nm_ip_routing_rule_from_string (cstr1,
|
||||||
|
NM_IP_ROUTING_RULE_AS_STRING_FLAGS_VALIDATE
|
||||||
|
| (nmtst_get_rand_bool () ? to_string_flags : NM_IP_ROUTING_RULE_AS_STRING_FLAGS_NONE),
|
||||||
|
NULL,
|
||||||
|
&error);
|
||||||
|
nmtst_assert_success (rr, error);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_assert (rr2);
|
||||||
|
vbool = nm_ip_routing_rule_validate (rr, &error);
|
||||||
|
nmtst_assert_success (vbool, error);
|
||||||
|
vbool = nm_ip_routing_rule_validate (rr2, &error);
|
||||||
|
nmtst_assert_success (vbool, error);
|
||||||
|
|
||||||
|
g_assert_cmpint (nm_ip_routing_rule_cmp (rr, rr2), ==, 0);
|
||||||
|
g_assert_cmpint (nm_ip_routing_rule_cmp (rr2, rr), ==, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
|
return g_steal_pointer (&rr);
|
||||||
|
}
|
||||||
|
#define _rr_from_str_get(a, ...) _rr_from_str_get_impl (a, &(NM_MAKE_STRV (NULL, ##__VA_ARGS__))[1])
|
||||||
|
|
||||||
|
#define _rr_from_str(...) \
|
||||||
|
G_STMT_START { \
|
||||||
|
nm_auto_unref_ip_routing_rule NMIPRoutingRule *_rr = NULL; \
|
||||||
|
\
|
||||||
|
_rr = _rr_from_str_get (__VA_ARGS__); \
|
||||||
|
g_assert (_rr); \
|
||||||
|
} G_STMT_END
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_routing_rule (gconstpointer test_data)
|
||||||
|
{
|
||||||
|
nm_auto_unref_ip_routing_rule NMIPRoutingRule *rr1 = NULL;
|
||||||
|
gboolean success;
|
||||||
|
char ifname_buf[16];
|
||||||
|
|
||||||
|
_rr_from_str ("priority 5 from 0.0.0.0 table 1",
|
||||||
|
" from 0.0.0\\.0 \\priority 5 lookup 1 ");
|
||||||
|
_rr_from_str ("priority 5 from 0.0.0.0/0 table 4");
|
||||||
|
_rr_from_str ("priority 5 to 0.0.0.0 table 6");
|
||||||
|
_rr_from_str ("priority 5 to 0.0.0.0 table 254",
|
||||||
|
"priority 5 to 0.0.0.0/32");
|
||||||
|
_rr_from_str ("priority 5 from 1.2.3.4 table 15",
|
||||||
|
"priority 5 from 1.2.3.4/32 table 0xF ",
|
||||||
|
"priority 5 from 1.2.3.4/32 to 0.0.0.0/0 lookup 15 ");
|
||||||
|
_rr_from_str ("priority 5 from 1.2.3.4 to 0.0.0.0 table 8");
|
||||||
|
_rr_from_str ("priority 5 to a:b:c:: tos 0x16 table 25",
|
||||||
|
"priority 5 to a:b:c::/128 table 0x19 tos 16",
|
||||||
|
"priority 5 to a:b:c::/128 lookup 0x19 dsfield 16",
|
||||||
|
"priority 5 to a:b:c::/128 lookup 0x19 dsfield 16 fwmark 0/0x00",
|
||||||
|
"priority 5 to a:b:c:: from all lookup 0x19 dsfield 16 fwmark 0x0/0");
|
||||||
|
_rr_from_str ("priority 5 from :: fwmark 0 table 25",
|
||||||
|
"priority 5 from ::/128 to all table 0x19 fwmark 0/0xFFFFFFFF",
|
||||||
|
"priority 5 from :: to ::/0 table 0x19 fwmark 0x00/4294967295");
|
||||||
|
_rr_from_str ("priority 5 from :: iif aab table 25");
|
||||||
|
_rr_from_str ("priority 5 from :: iif aab oif er table 25",
|
||||||
|
"priority 5 from :: table 0x19 dev \\a\\a\\b oif er");
|
||||||
|
_rr_from_str ("priority 5 from :: iif a\\\\303b table 25");
|
||||||
|
_rr_from_str ("priority 5 to 0.0.0.0 sport 10 table 6",
|
||||||
|
"priority 5 to 0.0.0.0 sport 10-10 table 6");
|
||||||
|
_rr_from_str ("not priority 5 to 0.0.0.0 dport 10-133 table 6",
|
||||||
|
"priority 5 to 0.0.0.0 not dport 10-133 not table 6",
|
||||||
|
"priority 5 to 0.0.0.0 not dport 10-\\ 133 not table 6");
|
||||||
|
_rr_from_str ("priority 5 to 0.0.0.0 ipproto 10 sport 10 table 6");
|
||||||
|
|
||||||
|
rr1 = _rr_from_str_get ("priority 5 from :: iif aab table 25");
|
||||||
|
g_assert_cmpstr (nm_ip_routing_rule_get_iifname (rr1), ==, "aab");
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, FALSE, ifname_buf);
|
||||||
|
g_assert (!success);
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, TRUE, ifname_buf);
|
||||||
|
g_assert_cmpstr (ifname_buf, ==, "aab");
|
||||||
|
g_assert (success);
|
||||||
|
|
||||||
|
rr1 = _rr_from_str_get ("priority 5 from :: iif a\\\\303\\\\261xb table 254");
|
||||||
|
g_assert_cmpstr (nm_ip_routing_rule_get_iifname (rr1), ==, "a\\303\\261xb");
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, FALSE, ifname_buf);
|
||||||
|
g_assert (!success);
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, TRUE, ifname_buf);
|
||||||
|
g_assert_cmpstr (ifname_buf, ==, "a\303\261xb");
|
||||||
|
g_assert (success);
|
||||||
|
nm_clear_pointer (&rr1, nm_ip_routing_rule_unref);
|
||||||
|
|
||||||
|
rr1 = _rr_from_str_get ("priority 5 from :: oif \\\\101=\\\\303\\\\261xb table 7");
|
||||||
|
g_assert_cmpstr (nm_ip_routing_rule_get_oifname (rr1), ==, "\\101=\\303\\261xb");
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, FALSE, ifname_buf);
|
||||||
|
g_assert_cmpstr (ifname_buf, ==, "A=\303\261xb");
|
||||||
|
g_assert (success);
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, TRUE, ifname_buf);
|
||||||
|
g_assert (!success);
|
||||||
|
nm_clear_pointer (&rr1, nm_ip_routing_rule_unref);
|
||||||
|
|
||||||
|
rr1 = _rr_from_str_get ("priority 5 to 0.0.0.0 tos 0x10 table 7");
|
||||||
|
g_assert_cmpstr (NULL, ==, nm_ip_routing_rule_get_from (rr1));
|
||||||
|
g_assert (!nm_ip_routing_rule_get_from_bin (rr1));
|
||||||
|
g_assert_cmpint (0, ==, nm_ip_routing_rule_get_from_len (rr1));
|
||||||
|
g_assert_cmpstr ("0.0.0.0", ==, nm_ip_routing_rule_get_to (rr1));
|
||||||
|
g_assert (nm_ip_addr_is_null (AF_INET, nm_ip_routing_rule_get_to_bin (rr1)));
|
||||||
|
g_assert_cmpint (32, ==, nm_ip_routing_rule_get_to_len (rr1));
|
||||||
|
g_assert_cmpint (7, ==, nm_ip_routing_rule_get_table (rr1));
|
||||||
|
g_assert_cmpint (0x10, ==, nm_ip_routing_rule_get_tos (rr1));
|
||||||
|
nm_clear_pointer (&rr1, nm_ip_routing_rule_unref);
|
||||||
|
|
||||||
|
rr1 = _rr_from_str_get ("priority 5 from :: iif a\\\\303\\\\261\\,x\\;b table 254",
|
||||||
|
"priority 5 from :: iif a\\\\303\\\\261,x;b table 254");
|
||||||
|
g_assert_cmpstr (nm_ip_routing_rule_get_iifname (rr1), ==, "a\\303\\261,x;b");
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, FALSE, ifname_buf);
|
||||||
|
g_assert (!success);
|
||||||
|
success = nm_ip_routing_rule_get_xifname_bin (rr1, TRUE, ifname_buf);
|
||||||
|
g_assert_cmpstr (ifname_buf, ==, "a\303\261,x;b");
|
||||||
|
g_assert (success);
|
||||||
|
nm_clear_pointer (&rr1, nm_ip_routing_rule_unref);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
NMTST_DEFINE ();
|
NMTST_DEFINE ();
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -2757,5 +2955,7 @@ main (int argc, char **argv)
|
|||||||
g_test_add_data_func ("/libnm/settings/roundtrip-conversion/wireguard/1", GINT_TO_POINTER (1), test_roundtrip_conversion);
|
g_test_add_data_func ("/libnm/settings/roundtrip-conversion/wireguard/1", GINT_TO_POINTER (1), test_roundtrip_conversion);
|
||||||
g_test_add_data_func ("/libnm/settings/roundtrip-conversion/wireguard/2", GINT_TO_POINTER (2), test_roundtrip_conversion);
|
g_test_add_data_func ("/libnm/settings/roundtrip-conversion/wireguard/2", GINT_TO_POINTER (2), test_roundtrip_conversion);
|
||||||
|
|
||||||
|
g_test_add_data_func ("/libnm/settings/routing-rule/1", GINT_TO_POINTER (0), test_routing_rule);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@@ -1536,13 +1536,57 @@ global:
|
|||||||
nm_bridge_vlan_set_untagged;
|
nm_bridge_vlan_set_untagged;
|
||||||
nm_bridge_vlan_to_str;
|
nm_bridge_vlan_to_str;
|
||||||
nm_bridge_vlan_unref;
|
nm_bridge_vlan_unref;
|
||||||
|
nm_ip_routing_rule_as_string_flags_get_type;
|
||||||
|
nm_ip_routing_rule_cmp;
|
||||||
|
nm_ip_routing_rule_from_string;
|
||||||
|
nm_ip_routing_rule_get_action;
|
||||||
|
nm_ip_routing_rule_get_addr_family;
|
||||||
|
nm_ip_routing_rule_get_destination_port_end;
|
||||||
|
nm_ip_routing_rule_get_destination_port_start;
|
||||||
|
nm_ip_routing_rule_get_from;
|
||||||
|
nm_ip_routing_rule_get_from_len;
|
||||||
|
nm_ip_routing_rule_get_fwmark;
|
||||||
|
nm_ip_routing_rule_get_fwmask;
|
||||||
|
nm_ip_routing_rule_get_iifname;
|
||||||
|
nm_ip_routing_rule_get_invert;
|
||||||
|
nm_ip_routing_rule_get_ipproto;
|
||||||
|
nm_ip_routing_rule_get_oifname;
|
||||||
|
nm_ip_routing_rule_get_priority;
|
||||||
|
nm_ip_routing_rule_get_source_port_end;
|
||||||
|
nm_ip_routing_rule_get_source_port_start;
|
||||||
|
nm_ip_routing_rule_get_table;
|
||||||
|
nm_ip_routing_rule_get_to;
|
||||||
|
nm_ip_routing_rule_get_to_len;
|
||||||
|
nm_ip_routing_rule_get_tos;
|
||||||
|
nm_ip_routing_rule_get_type;
|
||||||
|
nm_ip_routing_rule_is_sealed;
|
||||||
|
nm_ip_routing_rule_new;
|
||||||
|
nm_ip_routing_rule_new_clone;
|
||||||
|
nm_ip_routing_rule_ref;
|
||||||
|
nm_ip_routing_rule_seal;
|
||||||
|
nm_ip_routing_rule_set_action;
|
||||||
|
nm_ip_routing_rule_set_destination_port;
|
||||||
|
nm_ip_routing_rule_set_from;
|
||||||
|
nm_ip_routing_rule_set_fwmark;
|
||||||
|
nm_ip_routing_rule_set_iifname;
|
||||||
|
nm_ip_routing_rule_set_invert;
|
||||||
|
nm_ip_routing_rule_set_ipproto;
|
||||||
|
nm_ip_routing_rule_set_oifname;
|
||||||
|
nm_ip_routing_rule_set_priority;
|
||||||
|
nm_ip_routing_rule_set_source_port;
|
||||||
|
nm_ip_routing_rule_set_table;
|
||||||
|
nm_ip_routing_rule_set_to;
|
||||||
|
nm_ip_routing_rule_set_tos;
|
||||||
|
nm_ip_routing_rule_to_string;
|
||||||
|
nm_ip_routing_rule_unref;
|
||||||
|
nm_ip_routing_rule_validate;
|
||||||
nm_lldp_neighbor_get_attr_value;
|
nm_lldp_neighbor_get_attr_value;
|
||||||
nm_setting_bridge_add_vlan;
|
nm_setting_bridge_add_vlan;
|
||||||
nm_setting_bridge_clear_vlans;
|
nm_setting_bridge_clear_vlans;
|
||||||
nm_setting_bridge_get_num_vlans;
|
nm_setting_bridge_get_num_vlans;
|
||||||
nm_setting_bridge_get_vlan;
|
nm_setting_bridge_get_vlan;
|
||||||
nm_setting_bridge_get_vlan_filtering;
|
|
||||||
nm_setting_bridge_get_vlan_default_pvid;
|
nm_setting_bridge_get_vlan_default_pvid;
|
||||||
|
nm_setting_bridge_get_vlan_filtering;
|
||||||
nm_setting_bridge_port_add_vlan;
|
nm_setting_bridge_port_add_vlan;
|
||||||
nm_setting_bridge_port_clear_vlans;
|
nm_setting_bridge_port_clear_vlans;
|
||||||
nm_setting_bridge_port_get_num_vlans;
|
nm_setting_bridge_port_get_num_vlans;
|
||||||
|
@@ -38,6 +38,9 @@ NM_AUTO_DEFINE_FCN0 (NMIPAddress *, _nm_ip_address_unref, nm_ip_address_unref)
|
|||||||
#define nm_auto_unref_ip_route nm_auto (_nm_auto_unref_ip_route)
|
#define nm_auto_unref_ip_route nm_auto (_nm_auto_unref_ip_route)
|
||||||
NM_AUTO_DEFINE_FCN0 (NMIPRoute *, _nm_auto_unref_ip_route, nm_ip_route_unref)
|
NM_AUTO_DEFINE_FCN0 (NMIPRoute *, _nm_auto_unref_ip_route, nm_ip_route_unref)
|
||||||
|
|
||||||
|
#define nm_auto_unref_ip_routing_rule nm_auto(_nm_auto_unref_ip_routing_rule)
|
||||||
|
NM_AUTO_DEFINE_FCN0 (NMIPRoutingRule *, _nm_auto_unref_ip_routing_rule, nm_ip_routing_rule_unref)
|
||||||
|
|
||||||
#define nm_auto_unref_sriov_vf nm_auto (_nm_auto_unref_sriov_vf)
|
#define nm_auto_unref_sriov_vf nm_auto (_nm_auto_unref_sriov_vf)
|
||||||
NM_AUTO_DEFINE_FCN0 (NMSriovVF *, _nm_auto_unref_sriov_vf, nm_sriov_vf_unref)
|
NM_AUTO_DEFINE_FCN0 (NMSriovVF *, _nm_auto_unref_sriov_vf, nm_sriov_vf_unref)
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user