about summary refs log tree commit diff
path: root/src/libnm-platform/nm-linux-platform.c
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2025-02-12 13:46:50 +0100
committerMichael Biebl <biebl@debian.org>2025-02-12 13:46:50 +0100
commit8bdf070ff046f482f6eb5e2b15ebc216f5d1e3da (patch)
treef706478d189d54c6532e8863d4b0d5ff5575af60 /src/libnm-platform/nm-linux-platform.c
parent818258cf34b83fbc754633295e1052d4752d7b15 (diff)
New upstream version 1.51.90 upstream/1.51.90
Diffstat (limited to 'src/libnm-platform/nm-linux-platform.c')
-rw-r--r--src/libnm-platform/nm-linux-platform.c81
1 files changed, 73 insertions, 8 deletions
diff --git a/src/libnm-platform/nm-linux-platform.c b/src/libnm-platform/nm-linux-platform.c
index f348e27c..24109568 100644
--- a/src/libnm-platform/nm-linux-platform.c
+++ b/src/libnm-platform/nm-linux-platform.c
@@ -865,6 +865,7 @@ static const LinkDesc link_descs[] = {
     [NM_LINK_TYPE_IP6GRE]      = {"ip6gre", "ip6gre", NULL},
     [NM_LINK_TYPE_IP6GRETAP]   = {"ip6gretap", "ip6gretap", NULL},
     [NM_LINK_TYPE_IPIP]        = {"ipip", "ipip", NULL},
+    [NM_LINK_TYPE_IPVLAN]      = {"ipvlan", "ipvlan", NULL},
     [NM_LINK_TYPE_LOOPBACK]    = {"loopback", NULL, NULL},
     [NM_LINK_TYPE_MACSEC]      = {"macsec", "macsec", NULL},
     [NM_LINK_TYPE_MACVLAN]     = {"macvlan", "macvlan", NULL},
@@ -912,6 +913,7 @@ _link_type_from_rtnl_type(const char *name)
         NM_LINK_TYPE_IP6GRETAP,   /* "ip6gretap"   */
         NM_LINK_TYPE_IP6TNL,      /* "ip6tnl"      */
         NM_LINK_TYPE_IPIP,        /* "ipip"        */
+        NM_LINK_TYPE_IPVLAN,      /* "ipvlan"      */
         NM_LINK_TYPE_MACSEC,      /* "macsec"      */
         NM_LINK_TYPE_MACVLAN,     /* "macvlan"     */
         NM_LINK_TYPE_MACVTAP,     /* "macvtap"     */
@@ -2111,6 +2113,40 @@ _parse_lnk_ipip(const char *kind, struct nlattr *info_data)
 /*****************************************************************************/
 
 static NMPObject *
+_parse_lnk_ipvlan(const char *kind, struct nlattr *info_data)
+{
+    static const struct nla_policy policy[] = {
+        [IFLA_IPVLAN_MODE]  = {.type = NLA_U16},
+        [IFLA_IPVLAN_FLAGS] = {.type = NLA_U16},
+    };
+    NMPlatformLnkIpvlan *props;
+    struct nlattr       *tb[G_N_ELEMENTS(policy)];
+    NMPObject           *obj;
+
+    if (!info_data || !kind)
+        return NULL;
+
+    if (nla_parse_nested_arr(tb, info_data, policy) < 0)
+        return NULL;
+
+    if (!tb[IFLA_IPVLAN_MODE])
+        return NULL;
+
+    obj         = nmp_object_new(NMP_OBJECT_TYPE_LNK_IPVLAN, NULL);
+    props       = &obj->lnk_ipvlan;
+    props->mode = nla_get_u16(tb[IFLA_IPVLAN_MODE]);
+
+    if (tb[IFLA_IPVLAN_FLAGS]) {
+        props->private_flag = NM_FLAGS_HAS(nla_get_u16(tb[IFLA_IPVLAN_FLAGS]), IPVLAN_F_PRIVATE);
+        props->vepa         = NM_FLAGS_HAS(nla_get_u16(tb[IFLA_IPVLAN_FLAGS]), IPVLAN_F_VEPA);
+    }
+
+    return obj;
+}
+
+/*****************************************************************************/
+
+static NMPObject *
 _parse_lnk_macvlan(const char *kind, struct nlattr *info_data)
 {
     static const struct nla_policy policy[] = {
@@ -2678,7 +2714,7 @@ _wireguard_update_from_allowed_ips_nla(NMPWireGuardAllowedIP *allowed_ip, struct
 
     _check_addr_or_return_val(tb, WGALLOWEDIP_A_IPADDR, addr_len, FALSE);
 
-    *allowed_ip = (NMPWireGuardAllowedIP){
+    *allowed_ip = (NMPWireGuardAllowedIP) {
         .family = family,
     };
 
@@ -2928,7 +2964,7 @@ _wireguard_read_info(NMPlatform     *platform /* used only as logging context */
     /* we ignore errors, and return whatever we could successfully
      * parse. */
     nl_recvmsgs(genl,
-                &((const struct nl_cb){
+                &((const struct nl_cb) {
                     .valid_cb  = _wireguard_get_device_cb,
                     .valid_arg = (gpointer) &parse_data,
                 }));
@@ -3365,7 +3401,7 @@ link_wireguard_change(NMPlatform                               *platform,
 static void
 _nmp_link_address_set(NMPLinkAddress *dst, const struct nlattr *nla)
 {
-    *dst = (NMPLinkAddress){
+    *dst = (NMPLinkAddress) {
         .len = 0,
     };
     if (nla) {
@@ -3674,6 +3710,9 @@ _new_from_nl_link(NMPlatform            *platform,
     case NM_LINK_TYPE_IPIP:
         lnk_data = _parse_lnk_ipip(nl_info_kind, nl_info_data);
         break;
+    case NM_LINK_TYPE_IPVLAN:
+        lnk_data = _parse_lnk_ipvlan(nl_info_kind, nl_info_data);
+        break;
     case NM_LINK_TYPE_MACSEC:
         lnk_data = _parse_lnk_macsec(nl_info_kind, nl_info_data);
         break;
@@ -5252,6 +5291,26 @@ _nl_msg_new_link_set_linkinfo(struct nl_msg *msg, NMLinkType link_type, gconstpo
         NLA_PUT_U8(msg, IFLA_IPTUN_PMTUDISC, !!props->path_mtu_discovery);
         break;
     }
+    case NM_LINK_TYPE_IPVLAN:
+    {
+        const NMPlatformLnkIpvlan *props = extra_data;
+        guint16                    flags = 0;
+
+        nm_assert(props);
+
+        if (!(data = nla_nest_start(msg, IFLA_INFO_DATA)))
+            goto nla_put_failure;
+
+        if (props->private_flag)
+            flags |= IPVLAN_F_PRIVATE;
+
+        if (props->vepa)
+            flags |= IPVLAN_F_VEPA;
+
+        NLA_PUT_U16(msg, IFLA_IPVLAN_MODE, props->mode);
+        NLA_PUT_U16(msg, IFLA_IPVLAN_FLAGS, flags);
+        break;
+    }
     case NM_LINK_TYPE_MACSEC:
     {
         const NMPlatformLnkMacsec *props = extra_data;
@@ -8156,7 +8215,7 @@ _rtnl_handle_msg(NMPlatform *platform, const struct nl_msg_lite *msg)
         is_del = TRUE;
     }
 
-    parse_nlmsg_iter = (ParseNlmsgIter){
+    parse_nlmsg_iter = (ParseNlmsgIter) {
         .iter_more = FALSE,
     };
 
@@ -9674,13 +9733,13 @@ link_get_bridge_vlans(NMPlatform            *platform,
         goto err;
     }
 
-    data = ((BridgeVlanData){
+    data = ((BridgeVlanData) {
         .ifindex = ifindex,
     });
 
     do {
         nle = nl_recvmsgs(sk,
-                          &((const struct nl_cb){
+                          &((const struct nl_cb) {
                               .valid_cb  = get_bridge_vlans_cb,
                               .valid_arg = &data,
                           }));
@@ -10655,6 +10714,7 @@ static int
 ip_route_get(NMPlatform   *platform,
              int           addr_family,
              gconstpointer address,
+             guint32       fwmark,
              int           oif_ifindex,
              NMPObject   **out_route)
 {
@@ -10689,6 +10749,11 @@ ip_route_get(NMPlatform   *platform,
         if (!_nl_addattr_l(&req.n, sizeof(req), RTA_DST, address, addr_len))
             nm_assert_not_reached();
 
+        if (fwmark != 0) {
+            if (!_nl_addattr_l(&req.n, sizeof(req), RTA_MARK, &fwmark, sizeof(fwmark)))
+                nm_assert_not_reached();
+        }
+
         if (oif_ifindex > 0) {
             gint32 ii = oif_ifindex;
 
@@ -11726,12 +11791,12 @@ mptcp_addrs_dump(NMPlatform *platform)
 
     addrs = g_ptr_array_new_with_free_func((GDestroyNotify) nmp_object_unref);
 
-    parse_data = (FetchMptcpAddrParseData){
+    parse_data = (FetchMptcpAddrParseData) {
         .addrs = addrs,
     };
 
     nl_recvmsgs(priv->sk_genl_sync,
-                &((const struct nl_cb){
+                &((const struct nl_cb) {
                     .valid_cb  = _mptcp_addrs_dump_parse_cb,
                     .valid_arg = (gpointer) &parse_data,
                 }));