diff options
author | Topi Miettinen <toiwoton@gmail.com> | 2022-08-28 07:09:55 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-08-29 14:23:17 +0900 |
commit | 5b198025def31d8f004d74f0001a844010bd650f (patch) | |
tree | 6bdf4dcaf21a72d639187b5d1727092003761e61 /src/libsystemd/sd-netlink | |
parent | 3f36b9ed477ce3b003d03e3dcca7376fbdcee1a4 (diff) | |
download | systemd-5b198025def31d8f004d74f0001a844010bd650f.tar.gz |
sd-netlink: add NetLabel support
Diffstat (limited to 'src/libsystemd/sd-netlink')
-rw-r--r-- | src/libsystemd/sd-netlink/netlink-types-genl.c | 25 | ||||
-rw-r--r-- | src/libsystemd/sd-netlink/test-netlink.c | 2 |
2 files changed, 20 insertions, 7 deletions
diff --git a/src/libsystemd/sd-netlink/netlink-types-genl.c b/src/libsystemd/sd-netlink/netlink-types-genl.c index 9d6d978b45..6fe9adcdbd 100644 --- a/src/libsystemd/sd-netlink/netlink-types-genl.c +++ b/src/libsystemd/sd-netlink/netlink-types-genl.c @@ -178,6 +178,16 @@ static const NLAPolicy genl_macsec_policies[] = { [MACSEC_ATTR_SA_CONFIG] = BUILD_POLICY_NESTED(genl_macsec_sa), }; +/***************** genl NetLabel type systems *****************/ +static const NLAPolicy genl_netlabel_policies[] = { + [NLBL_UNLABEL_A_IPV4ADDR] = BUILD_POLICY(IN_ADDR), + [NLBL_UNLABEL_A_IPV4MASK] = BUILD_POLICY(IN_ADDR), + [NLBL_UNLABEL_A_IPV6ADDR] = BUILD_POLICY_WITH_SIZE(IN_ADDR, sizeof(struct in6_addr)), + [NLBL_UNLABEL_A_IPV6MASK] = BUILD_POLICY_WITH_SIZE(IN_ADDR, sizeof(struct in6_addr)), + [NLBL_UNLABEL_A_IFACE] = BUILD_POLICY_WITH_SIZE(STRING, IFNAMSIZ-1), + [NLBL_UNLABEL_A_SECCTX] = BUILD_POLICY(STRING), +}; + /***************** genl nl80211 type systems *****************/ static const NLAPolicy genl_nl80211_policies[] = { [NL80211_ATTR_WIPHY] = BUILD_POLICY(U32), @@ -223,13 +233,14 @@ static const NLAPolicy genl_wireguard_policies[] = { /***************** genl families *****************/ static const NLAPolicySetUnionElement genl_policy_set_union_elements[] = { - BUILD_UNION_ELEMENT_BY_STRING(CTRL_GENL_NAME, genl_ctrl), - BUILD_UNION_ELEMENT_BY_STRING(BATADV_NL_NAME, genl_batadv), - BUILD_UNION_ELEMENT_BY_STRING(FOU_GENL_NAME, genl_fou), - BUILD_UNION_ELEMENT_BY_STRING(L2TP_GENL_NAME, genl_l2tp), - BUILD_UNION_ELEMENT_BY_STRING(MACSEC_GENL_NAME, genl_macsec), - BUILD_UNION_ELEMENT_BY_STRING(NL80211_GENL_NAME, genl_nl80211), - BUILD_UNION_ELEMENT_BY_STRING(WG_GENL_NAME, genl_wireguard), + BUILD_UNION_ELEMENT_BY_STRING(CTRL_GENL_NAME, genl_ctrl), + BUILD_UNION_ELEMENT_BY_STRING(BATADV_NL_NAME, genl_batadv), + BUILD_UNION_ELEMENT_BY_STRING(FOU_GENL_NAME, genl_fou), + BUILD_UNION_ELEMENT_BY_STRING(L2TP_GENL_NAME, genl_l2tp), + BUILD_UNION_ELEMENT_BY_STRING(MACSEC_GENL_NAME, genl_macsec), + BUILD_UNION_ELEMENT_BY_STRING(NETLBL_NLTYPE_UNLABELED_NAME, genl_netlabel), + BUILD_UNION_ELEMENT_BY_STRING(NL80211_GENL_NAME, genl_nl80211), + BUILD_UNION_ELEMENT_BY_STRING(WG_GENL_NAME, genl_wireguard), }; /* This is the root type system union, so match_attribute is not necessary. */ diff --git a/src/libsystemd/sd-netlink/test-netlink.c b/src/libsystemd/sd-netlink/test-netlink.c index 5eda53b596..50e9d64663 100644 --- a/src/libsystemd/sd-netlink/test-netlink.c +++ b/src/libsystemd/sd-netlink/test-netlink.c @@ -656,6 +656,8 @@ static void test_genl(void) { (void) sd_genl_message_new(genl, MACSEC_GENL_NAME, 0, &m); m = sd_netlink_message_unref(m); (void) sd_genl_message_new(genl, NL80211_GENL_NAME, 0, &m); + m = sd_netlink_message_unref(m); + (void) sd_genl_message_new(genl, NETLBL_NLTYPE_UNLABELED_NAME, 0, &m); for (;;) { r = sd_event_run(event, 500 * USEC_PER_MSEC); |