Skip to content

Commit

Permalink
ip_tunnels: convert the mode field of ip_tunnel_info to flags
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Alexei Starovoitov <[email protected]>
Acked-by: Thomas Graf <[email protected]>
Acked-by: Pravin B Shelar <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Benc authored and davem330 committed Aug 29, 2015
1 parent f6d3c19 commit 46fa062
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 13 deletions.
2 changes: 1 addition & 1 deletion drivers/net/geneve.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/vxlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion include/net/dst_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
9 changes: 2 additions & 7 deletions include/net/ip_tunnels.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/ip_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 46fa062

Please sign in to comment.