ovsdb: Add support for weak references.
[openvswitch] / lib / netdev-linux.c
index 5341ed06f0fa0eabfbf8ce9503a29a01c27aad9e..736b588a8a11638555e83a047960402f20ac8755 100644 (file)
@@ -123,10 +123,12 @@ struct gre_config {
     uint32_t remote_ip;
     uint32_t in_key;
     uint32_t out_key;
+    uint8_t tos;
     bool have_in_key;
     bool have_out_key;
     bool in_csum;
     bool out_csum;
+    bool pmtud;
 };
 
 static struct {
@@ -256,7 +258,6 @@ setup_gre_netlink(const char *name OVS_UNUSED,
     struct nlattr *info_data_hdr;
     uint16_t iflags = 0;
     uint16_t oflags = 0;
-    uint8_t pmtudisc = 0;
 
     VLOG_DBG("%s: attempting to create gre device using netlink", name);
 
@@ -315,9 +316,9 @@ setup_gre_netlink(const char *name OVS_UNUSED,
     nl_msg_put_u16(&request, IFLA_GRE_OFLAGS, oflags);
     nl_msg_put_u32(&request, IFLA_GRE_LOCAL, config->local_ip);
     nl_msg_put_u32(&request, IFLA_GRE_REMOTE, config->remote_ip);
-    nl_msg_put_u8(&request, IFLA_GRE_PMTUDISC, pmtudisc);
-    nl_msg_put_u8(&request, IFLA_GRE_TTL, 0);
-    nl_msg_put_u8(&request, IFLA_GRE_TOS, 0);
+    nl_msg_put_u8(&request, IFLA_GRE_PMTUDISC, config->pmtud);
+    nl_msg_put_u8(&request, IFLA_GRE_TTL, IPDEFTTL);
+    nl_msg_put_u8(&request, IFLA_GRE_TOS, config->tos);
 
     info_data_hdr->nla_len = (char *)ofpbuf_tail(&request)
                                 - (char *)info_data_hdr;
@@ -356,6 +357,8 @@ setup_gre_ioctl(const char *name, struct gre_config *config, bool create)
     p.iph.protocol = IPPROTO_GRE;
     p.iph.saddr = config->local_ip;
     p.iph.daddr = config->remote_ip;
+    p.iph.ttl = IPDEFTTL;
+    p.iph.tos = config->tos;
 
     if (config->have_in_key) {
         p.i_flags |= GRE_KEY;
@@ -373,6 +376,10 @@ setup_gre_ioctl(const char *name, struct gre_config *config, bool create)
         p.o_flags |= GRE_CSUM;
     }
 
+    if (config->pmtud) {
+        p.iph.frag_off = htons(IP_DONT_FRAGMENT);
+    }
+
     strncpy(ifr.ifr_name, create ? GRE_IOCTL_DEVICE : name, IFNAMSIZ);
     ifr.ifr_ifru.ifru_data = (void *)&p;
 
@@ -486,6 +493,7 @@ setup_gre(const char *name, const struct shash *args, bool create)
     memset(&config, 0, sizeof config);
     config.in_csum = true;
     config.out_csum = true;
+    config.pmtud = true;
 
     SHASH_FOR_EACH (node, args) {
         if (!strcmp(node->name, "remote_ip")) {
@@ -511,11 +519,17 @@ setup_gre(const char *name, const struct shash *args, bool create)
         } else if (!strcmp(node->name, "out_key")) {
             config.have_out_key = true;
             config.out_key = htonl(atoi(node->data));
+        } else if (!strcmp(node->name, "tos")) {
+            config.tos = atoi(node->data);
         } else if (!strcmp(node->name, "csum")) {
             if (!strcmp(node->data, "false")) {
                 config.in_csum = false;
                 config.out_csum = false;
             }
+        } else if (!strcmp(node->name, "pmtud")) {
+            if (!strcmp(node->data, "false")) {
+                config.pmtud = false;
+            }
         } else {
             VLOG_WARN("unknown gre argument '%s'", node->name);
         }