chiark / gitweb /
networkd: support vxlan parameters
[elogind.git] / src / network / networkd-netdev-vxlan.c
index 7dec69d0f61dee649d20e3e24033bda03a79f413..b19240e311a0b974ba891ceb50d0814098901055 100644 (file)
@@ -26,6 +26,7 @@
 #include "sd-rtnl.h"
 #include "networkd-netdev-vxlan.h"
 #include "networkd-link.h"
+#include "conf-parser.h"
 #include "missing.h"
 
 static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
@@ -92,9 +93,89 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
                 return r;
         }
 
+        r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_RSC, v->route_short_circuit);
+        if (r < 0) {
+                log_error_netdev(netdev,
+                                 "Could not append IFLA_VXLAN_RSC attribute: %s",
+                                 strerror(-r));
+                return r;
+        }
+
+        r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_PROXY, v->arp_proxy);
+        if (r < 0) {
+                log_error_netdev(netdev,
+                                 "Could not append IFLA_VXLAN_PROXY attribute: %s",
+                                 strerror(-r));
+                return r;
+        }
+
+        r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L2MISS, v->l2miss);
+        if (r < 0) {
+                log_error_netdev(netdev,
+                                 "Could not append IFLA_VXLAN_L2MISS attribute: %s",
+                                 strerror(-r));
+                return r;
+        }
+
+        r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L3MISS, v->l3miss);
+        if (r < 0) {
+                log_error_netdev(netdev,
+                                 "Could not append IFLA_VXLAN_L3MISS attribute: %s",
+                                 strerror(-r));
+                return r;
+        }
+
+        if(v->fdb_ageing) {
+                r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_AGEING, v->fdb_ageing / USEC_PER_SEC);
+                if (r < 0) {
+                        log_error_netdev(netdev,
+                                         "Could not append IFLA_VXLAN_AGEING attribute: %s",
+                                         strerror(-r));
+                        return r;
+                }
+        }
+
         return r;
 }
 
+int config_parse_vxlan_group_address(const char *unit,
+                                     const char *filename,
+                                     unsigned line,
+                                     const char *section,
+                                     unsigned section_line,
+                                     const char *lvalue,
+                                     int ltype,
+                                     const char *rvalue,
+                                     void *data,
+                                     void *userdata) {
+        VxLan *v = userdata;
+        union in_addr_union *addr = data, buffer;
+        int r, f;
+
+        assert(filename);
+        assert(lvalue);
+        assert(rvalue);
+        assert(data);
+
+        r = in_addr_from_string_auto(rvalue, &f, &buffer);
+        if (r < 0) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "vxlan multicast group address is invalid, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        if(v->family != AF_UNSPEC && v->family != f) {
+                log_syntax(unit, LOG_ERR, filename, line, EINVAL,
+                           "vxlan multicast group incompatible, ignoring assignment: %s", rvalue);
+                return 0;
+        }
+
+        v->family = f;
+        *addr = buffer;
+
+        return 0;
+}
+
 static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
         VxLan *v = VXLAN(netdev);