]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
gre/gre6: Unify attribute addition to netlink buffer
authorSerhey Popovych <serhe.popovych@gmail.com>
Mon, 22 Jan 2018 17:23:46 +0000 (19:23 +0200)
committerDavid Ahern <dsahern@gmail.com>
Wed, 24 Jan 2018 18:01:30 +0000 (10:01 -0800)
There are couple of minor improvements:

  1) Check erspan_ver == 2 in gre6. It still could
     be 1 if erspan_idx is 0.

  2) Add tunnel encapsulation attributes only when
     collect metadata not in effect in gre.

  3) Trivial: address checkpatch issues.

Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
ip/link_gre.c
ip/link_gre6.c

index c7e65fcfade63dab7a018b5e1ac60efb6eb495d2..d91a435bca74ce5f81c8155a173723592d9fcaa2 100644 (file)
@@ -362,6 +362,8 @@ get_failed:
                addattr_l(n, 1024, IFLA_GRE_LOCAL, &saddr, 4);
                addattr_l(n, 1024, IFLA_GRE_REMOTE, &daddr, 4);
                addattr_l(n, 1024, IFLA_GRE_PMTUDISC, &pmtudisc, 1);
+               if (ignore_df)
+                       addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
                if (link)
                        addattr32(n, 1024, IFLA_GRE_LINK, link);
                addattr_l(n, 1024, IFLA_GRE_TTL, &ttl, 1);
@@ -370,24 +372,23 @@ get_failed:
                if (erspan_ver) {
                        addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
                        if (erspan_ver == 1 && erspan_idx != 0) {
-                               addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
+                               addattr32(n, 1024,
+                                         IFLA_GRE_ERSPAN_INDEX, erspan_idx);
                        } else if (erspan_ver == 2) {
-                               addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
-                               addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
+                               addattr8(n, 1024,
+                                        IFLA_GRE_ERSPAN_DIR, erspan_dir);
+                               addattr16(n, 1024,
+                                         IFLA_GRE_ERSPAN_HWID, erspan_hwid);
                        }
                }
+               addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
+               addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
+               addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
+               addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
        } else {
                addattr_l(n, 1024, IFLA_GRE_COLLECT_METADATA, NULL, 0);
        }
 
-       addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
-       addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
-       addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
-       addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
-
-       if (ignore_df)
-               addattr8(n, 1024, IFLA_GRE_IGNORE_DF, ignore_df & 1);
-
        return 0;
 }
 
index 3500b529aac86d8b964bfe2ed14a2a83d9bd2323..b3f070ba63121ca891e1c6fce074b8c19d9fcf2b 100644 (file)
@@ -406,10 +406,13 @@ get_failed:
                if (erspan_ver) {
                        addattr8(n, 1024, IFLA_GRE_ERSPAN_VER, erspan_ver);
                        if (erspan_ver == 1 && erspan_idx != 0) {
-                               addattr32(n, 1024, IFLA_GRE_ERSPAN_INDEX, erspan_idx);
-                       } else {
-                               addattr8(n, 1024, IFLA_GRE_ERSPAN_DIR, erspan_dir);
-                               addattr16(n, 1024, IFLA_GRE_ERSPAN_HWID, erspan_hwid);
+                               addattr32(n, 1024,
+                                         IFLA_GRE_ERSPAN_INDEX, erspan_idx);
+                       } else if (erspan_ver == 2) {
+                               addattr8(n, 1024,
+                                        IFLA_GRE_ERSPAN_DIR, erspan_dir);
+                               addattr16(n, 1024,
+                                         IFLA_GRE_ERSPAN_HWID, erspan_hwid);
                        }
                }
                addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
@@ -604,7 +607,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 }
 
 static void gre_print_help(struct link_util *lu, int argc, char **argv,
-       FILE *f)
+                          FILE *f)
 {
        print_usage(f);
 }