ip_tunnels: convert the mode field of ip_tunnel_info to flags
authorJiri Benc <jbenc@redhat.com>
Fri, 28 Aug 2015 18:48:19 +0000 (20:48 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 29 Aug 2015 20:07:54 +0000 (13:07 -0700)
The mode field holds a single bit of information only (whether the
ip_tunnel_info struct is for rx or tx). Change the mode field to bit flags.
This allows more mode flags to be added.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
Acked-by: Alexei Starovoitov <ast@plumgrid.com>
Acked-by: Thomas Graf <tgraf@suug.ch>
Acked-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/geneve.c
drivers/net/vxlan.c
include/net/dst_metadata.h
include/net/ip_tunnels.h
net/ipv4/ip_gre.c
net/ipv4/route.c
net/ipv6/route.c

index 4357bae732d738f275788dde25cdc72a9ae0b622..4a39c09f144c078d994ba11bba0315d5cd2c1633 100644 (file)
@@ -623,7 +623,7 @@ static netdev_tx_t geneve_xmit(struct sk_buff *skb, struct net_device *dev)
 
        if (geneve->collect_md) {
                info = skb_tunnel_info(skb);
-               if (unlikely(info && info->mode != IP_TUNNEL_INFO_TX)) {
+               if (unlikely(info && !(info->mode & IP_TUNNEL_INFO_TX))) {
                        netdev_dbg(dev, "no tunnel metadata\n");
                        goto tx_error;
                }
index 30e56cb5888495df97b90844a0a7281713f0d56e..bd1b8cdf2bf6febf06cd8016f5e27d0e44937229 100644 (file)
@@ -2113,7 +2113,7 @@ static netdev_tx_t vxlan_xmit(struct sk_buff *skb, struct net_device *dev)
        }
 
        if (vxlan->flags & VXLAN_F_COLLECT_METADATA &&
-           info && info->mode == IP_TUNNEL_INFO_TX) {
+           info && info->mode & IP_TUNNEL_INFO_TX) {
                vxlan_xmit_one(skb, dev, NULL, false);
                return NETDEV_TX_OK;
        }
index 60c03326c0876da848a31b8d45ac0bb0dfc10f4f..2b83f0d232e09949f1c99fc6164590401ebb0927 100644 (file)
@@ -59,7 +59,6 @@ static inline struct metadata_dst *tun_rx_dst(__be16 flags,
                return NULL;
 
        info = &tun_dst->u.tun_info;
-       info->mode = IP_TUNNEL_INFO_RX;
        info->key.tun_flags = flags;
        info->key.tun_id = tunnel_id;
        info->key.tp_src = 0;
index 224e4ecec91b71eb626e8f37e3785e6ded52c92c..9bdb3948798fd14569f82dddadd41ef5fe1254b5 100644 (file)
@@ -50,13 +50,8 @@ struct ip_tunnel_key {
        __be16                  tp_dst;
 };
 
-/* Indicates whether the tunnel info structure represents receive
- * or transmit tunnel parameters.
- */
-enum {
-       IP_TUNNEL_INFO_RX,
-       IP_TUNNEL_INFO_TX,
-};
+/* Flags for ip_tunnel_info mode. */
+#define IP_TUNNEL_INFO_TX      0x01    /* represents tx tunnel parameters */
 
 struct ip_tunnel_info {
        struct ip_tunnel_key    key;
index faf1cde6f8da2486b5f6dbd955b8f0196e1af9f1..1e813a9f9378f8520dae4ee28cf0740d6a2796b7 100644 (file)
@@ -511,7 +511,7 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev)
        int err;
 
        tun_info = skb_tunnel_info(skb);
-       if (unlikely(!tun_info || tun_info->mode != IP_TUNNEL_INFO_TX))
+       if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX)))
                goto err_free_skb;
 
        key = &tun_info->key;
index 6b91879e9cbe5e574ff562306472111a2fb66377..5f4a5565ad8b32ef7d10619364a86713d52f38e0 100644 (file)
@@ -1696,7 +1696,7 @@ static int ip_route_input_slow(struct sk_buff *skb, __be32 daddr, __be32 saddr,
         */
 
        tun_info = skb_tunnel_info(skb);
-       if (tun_info && tun_info->mode == IP_TUNNEL_INFO_RX)
+       if (tun_info && !(tun_info->mode & IP_TUNNEL_INFO_TX))
                fl4.flowi4_tun_key.tun_id = tun_info->key.tun_id;
        else
                fl4.flowi4_tun_key.tun_id = 0;
index df3e353a012d081699df247482c9932a9f69ee9c..308dd5f9158f17bd140a413d5fd63d6d99b25d16 100644 (file)
@@ -1174,7 +1174,7 @@ void ip6_route_input(struct sk_buff *skb)
        };
 
        tun_info = skb_tunnel_info(skb);
-       if (tun_info && tun_info->mode == IP_TUNNEL_INFO_RX)
+       if (tun_info && !(tun_info->mode & IP_TUNNEL_INFO_TX))
                fl6.flowi6_tun_key.tun_id = tun_info->key.tun_id;
        skb_dst_drop(skb);
        skb_dst_set(skb, ip6_route_input_lookup(net, skb->dev, &fl6, flags));