Browse Source

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 <ansuelsmth@gmail.com>
Christian Marangi 5 months ago
parent
commit
841b05fbb9
1 changed files with 8 additions and 0 deletions
  1. 8 0
      system-linux.c

+ 8 - 0
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);
 }