From: Christian Marangi Date: Thu, 9 Nov 2023 16:24:36 +0000 (+0100) Subject: system-linux: fix compilation error if IFLA_DSA_MASTER is not supported X-Git-Url: http://git.openwrt.org/?p=project%2Fnetifd.git;a=commitdiff_plain;h=841b05fbb91eb7076ec3170756693bd4f1e9708e system-linux: fix compilation error if IFLA_DSA_MASTER is not supported Changing DSA port conduit was introduced only with kernel 6.1. Fix compilation error by disabling support for this on unsupported kernels. Signed-off-by: Christian Marangi --- diff --git a/system-linux.c b/system-linux.c index 00530f2..147569d 100644 --- a/system-linux.c +++ b/system-linux.c @@ -1714,6 +1714,7 @@ int system_vlandev_del(struct device *vlandev) return system_link_del(vlandev->ifname); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) struct if_get_master_data { int ifindex; int master_ifindex; @@ -1876,6 +1877,7 @@ static void system_set_master(struct device *dev, int master_ifindex) failure: nlmsg_free(nlm); } +#endif static void ethtool_link_mode_clear_bit(__s8 nwords, int nr, __u32 *mask) { @@ -2197,11 +2199,13 @@ system_if_get_settings(struct device *dev, struct device_settings *s) s->flags |= DEV_OPT_GRO; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) ret = system_if_get_master_ifindex(dev); if (ret >= 0) { s->master_ifindex = ret; s->flags |= DEV_OPT_MASTER; } +#endif } void @@ -2301,7 +2305,11 @@ system_if_apply_settings(struct device *dev, struct device_settings *s, uint64_t if (apply_mask & DEV_OPT_ARP_ACCEPT) system_set_arp_accept(dev, s->arp_accept ? "1" : "0"); if (apply_mask & DEV_OPT_MASTER) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,1,0) system_set_master(dev, s->master_ifindex); +#else + netifd_log_message(L_WARNING, "%s Your kernel is older than linux 6.1.0, changing DSA port conduit is not supported!", dev->ifname); +#endif system_set_ethtool_settings(dev, s); }