We always send flowinfo to the kernel. If flowlabel/tclass
was set first to non-inherit value and then reset to
inherit we do not clear flowlabel/tclass part in flowinfo,
send it to kernel and can get from the kernel back.

Even if we check for IP6_TNL_F_USE_ORIG_TCLASS and
IP6_TNL_F_USE_ORIG_FLOWLABEL when printing options
sending invalid flowlabel/tclass to the kernel seems
bad idea.

Note that ip6tnl always clean corresponding flowinfo
parts on inherit.

Signed-off-by: Serhey Popovych <serhe.popov...@gmail.com>
---
 ip/link_gre6.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index a3e8e08..7ae4b49 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -251,12 +251,12 @@ get_failed:
                        __u8 uval;
 
                        NEXT_ARG();
+                       flowinfo &= ~IP6_FLOWINFO_TCLASS;
                        if (strcmp(*argv, "inherit") == 0)
                                flags |= IP6_TNL_F_USE_ORIG_TCLASS;
                        else {
                                if (get_u8(&uval, *argv, 16))
                                        invarg("invalid TClass", *argv);
-                               flowinfo &= ~IP6_FLOWINFO_TCLASS;
                                flowinfo |= htonl((__u32)uval << 20) & 
IP6_FLOWINFO_TCLASS;
                                flags &= ~IP6_TNL_F_USE_ORIG_TCLASS;
                        }
@@ -265,6 +265,7 @@ get_failed:
                        __u32 uval;
 
                        NEXT_ARG();
+                       flowinfo &= ~IP6_FLOWINFO_FLOWLABEL;
                        if (strcmp(*argv, "inherit") == 0)
                                flags |= IP6_TNL_F_USE_ORIG_FLOWLABEL;
                        else {
@@ -272,7 +273,6 @@ get_failed:
                                        invarg("invalid Flowlabel", *argv);
                                if (uval > 0xFFFFF)
                                        invarg("invalid Flowlabel", *argv);
-                               flowinfo &= ~IP6_FLOWINFO_FLOWLABEL;
                                flowinfo |= htonl(uval) & 
IP6_FLOWINFO_FLOWLABEL;
                                flags &= ~IP6_TNL_F_USE_ORIG_FLOWLABEL;
                        }
-- 
1.7.10.4

Reply via email to