From d2c58bc64d66989a1957cd05e4b30ce742832e8c Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 17 Aug 2020 09:49:42 +0200 Subject: [PATCH] platform: set default values for NMPlatformLnkBridge if unspecified on netlink Older kernels may not support or send all bridge options in the netlink message. In case the parameter is missing, set the default value. Note that there may be future cases where we need to encode whether the option is present or not. Currently we don't express that. --- src/platform/nm-linux-platform.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index a5b7b710a..6fd92ac9d 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -1346,22 +1346,40 @@ _parse_lnk_bridge (const char *kind, struct nlattr *info_data) props->priority = nla_get_u16 (tb[IFLA_BR_PRIORITY]); if (tb[IFLA_BR_GROUP_FWD_MASK]) props->group_fwd_mask = nla_get_u16 (tb[IFLA_BR_GROUP_FWD_MASK]); + else + props->group_fwd_mask = 0; if (tb[IFLA_BR_MCAST_LAST_MEMBER_CNT]) props->mcast_last_member_count = nla_get_u32 (tb[IFLA_BR_MCAST_LAST_MEMBER_CNT]); + else + props->mcast_last_member_count = NM_BRIDGE_MULTICAST_LAST_MEMBER_COUNT_DEF; if (tb[IFLA_BR_MCAST_LAST_MEMBER_INTVL]) props->mcast_last_member_interval = nla_get_u64 (tb[IFLA_BR_MCAST_LAST_MEMBER_INTVL]); + else + props->mcast_last_member_interval = NM_BRIDGE_MULTICAST_LAST_MEMBER_INTERVAL_DEF; if (tb[IFLA_BR_MCAST_MEMBERSHIP_INTVL]) props->mcast_membership_interval = nla_get_u64 (tb[IFLA_BR_MCAST_MEMBERSHIP_INTVL]); + else + props->mcast_membership_interval = NM_BRIDGE_MULTICAST_MEMBERSHIP_INTERVAL_DEF; if (tb[IFLA_BR_MCAST_QUERIER_INTVL]) props->mcast_querier_interval = nla_get_u64 (tb[IFLA_BR_MCAST_QUERIER_INTVL]); + else + props->mcast_querier_interval = NM_BRIDGE_MULTICAST_QUERIER_INTERVAL_DEF; if (tb[IFLA_BR_MCAST_QUERY_INTVL]) props->mcast_query_interval = nla_get_u64 (tb[IFLA_BR_MCAST_QUERY_INTVL]); + else + props->mcast_query_interval = NM_BRIDGE_MULTICAST_QUERY_INTERVAL_DEF; if (tb[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL]) props->mcast_query_response_interval = nla_get_u64 (tb[IFLA_BR_MCAST_QUERY_RESPONSE_INTVL]); + else + props->mcast_query_response_interval = NM_BRIDGE_MULTICAST_QUERY_RESPONSE_INTERVAL_DEF; if (tb[IFLA_BR_MCAST_STARTUP_QUERY_CNT]) props->mcast_startup_query_count = nla_get_u32 (tb[IFLA_BR_MCAST_STARTUP_QUERY_CNT]); + else + props->mcast_startup_query_count = NM_BRIDGE_MULTICAST_STARTUP_QUERY_COUNT_DEF; if (tb[IFLA_BR_MCAST_STARTUP_QUERY_INTVL]) props->mcast_startup_query_interval = nla_get_u64 (tb[IFLA_BR_MCAST_STARTUP_QUERY_INTVL]); + else + props->mcast_startup_query_interval = NM_BRIDGE_MULTICAST_STARTUP_QUERY_INTERVAL_DEF; return obj; }