system-linux: VXLAN: add options to enable and disable UDP checksums
authorMatthias Schiffer <mschiffer@universe-factory.net>
Wed, 24 Jan 2018 12:21:44 +0000 (13:21 +0100)
committerMatthias Schiffer <mschiffer@universe-factory.net>
Wed, 24 Jan 2018 12:21:44 +0000 (13:21 +0100)
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
system-linux.c
system.c
system.h

index 32d6ffc..0277886 100644 (file)
@@ -2841,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;
index 5555272..e236e96 100644 (file)
--- a/system.c
+++ b/system.c
@@ -36,6 +36,8 @@ static const struct blobmsg_policy vxlan_data_attrs[__VXLAN_DATA_ATTR_MAX] = {
        [VXLAN_DATA_ATTR_ID] = { .name = "id", .type = BLOBMSG_TYPE_INT32 },
        [VXLAN_DATA_ATTR_PORT] = { .name = "port", .type = BLOBMSG_TYPE_INT32 },
        [VXLAN_DATA_ATTR_MACADDR] = { .name = "macaddr", .type = BLOBMSG_TYPE_STRING },
+       [VXLAN_DATA_ATTR_RXCSUM] = { .name = "rxcsum", .type = BLOBMSG_TYPE_BOOL },
+       [VXLAN_DATA_ATTR_TXCSUM] = { .name = "txcsum", .type = BLOBMSG_TYPE_BOOL },
 };
 
 const struct uci_blob_param_list vxlan_data_attr_list = {
index 61c72c2..371a524 100644 (file)
--- a/system.h
+++ b/system.h
@@ -41,6 +41,8 @@ enum vxlan_data {
        VXLAN_DATA_ATTR_ID,
        VXLAN_DATA_ATTR_PORT,
        VXLAN_DATA_ATTR_MACADDR,
+       VXLAN_DATA_ATTR_RXCSUM,
+       VXLAN_DATA_ATTR_TXCSUM,
        __VXLAN_DATA_ATTR_MAX
 };