system-linux: VXLAN: add options to enable and disable UDP checksums
[project/netifd.git] / system-linux.c
index 6d97a02..0277886 100644 (file)
@@ -543,16 +543,20 @@ out:
 static void
 handle_hotplug_msg(char *data, int size)
 {
-       const char *subsystem = NULL, *interface = NULL;
+       const char *subsystem = NULL, *interface = NULL, *interface_old = NULL;
        char *cur, *end, *sep;
        struct device *dev;
        int skip;
-       bool add;
+       bool add, move = false;
 
        if (!strncmp(data, "add@", 4))
                add = true;
        else if (!strncmp(data, "remove@", 7))
                add = false;
+       else if (!strncmp(data, "move@", 5)) {
+               add = true;
+               move = true;
+       }
        else
                return;
 
@@ -573,12 +577,32 @@ handle_hotplug_msg(char *data, int size)
                        subsystem = sep + 1;
                        if (strcmp(subsystem, "net") != 0)
                                return;
+               } else if (!strcmp(cur, "DEVPATH_OLD")) {
+                       interface_old = strrchr(sep + 1, '/');
+                       if (interface_old)
+                               interface_old++;
                }
-               if (subsystem && interface)
+       }
+
+       if (subsystem && interface) {
+               if (move && interface_old)
+                       goto move;
+               else
                        goto found;
        }
+
        return;
 
+move:
+       dev = device_find(interface_old);
+       if (!dev)
+               goto found;
+
+       if (dev->type != &simple_device_type)
+               goto found;
+
+       device_set_present(dev, false);
+
 found:
        dev = device_find(interface);
        if (!dev)
@@ -2817,6 +2841,17 @@ static int system_add_vxlan(const char *name, const unsigned int link, struct bl
        }
        nla_put_u16(msg, IFLA_VXLAN_PORT, htons(port));
 
+       if ((cur = tb_data[VXLAN_DATA_ATTR_RXCSUM])) {
+               bool rxcsum = blobmsg_get_bool(cur);
+               nla_put_u8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_RX, !rxcsum);
+       }
+
+       if ((cur = tb_data[VXLAN_DATA_ATTR_TXCSUM])) {
+               bool txcsum = blobmsg_get_bool(cur);
+               nla_put_u8(msg, IFLA_VXLAN_UDP_CSUM, txcsum);
+               nla_put_u8(msg, IFLA_VXLAN_UDP_ZERO_CSUM6_TX, !txcsum);
+       }
+
        if ((cur = tb[TUNNEL_ATTR_TOS])) {
                char *str = blobmsg_get_string(cur);
                unsigned tos = 1;