Skip to content

Commit

Permalink
datapath: Add support for 3.6 kernel.
Browse files Browse the repository at this point in the history
Signed-off-by: Pravin B Shelar <[email protected]>
Acked-by: Jesse Gross <[email protected]>
  • Loading branch information
Pravin B Shelar committed Nov 5, 2012
1 parent 05a9d48 commit 70cf679
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions datapath/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@
#include "vport-internal_dev.h"

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) || \
LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)
#error Kernels before 2.6.18 or after 3.5 are not supported by this version of Open vSwitch.
LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)
#error Kernels before 2.6.18 or after 3.6 are not supported by this version of Open vSwitch.
#endif

#define REHASH_FLOW_INTERVAL (10 * 60 * HZ)
Expand Down
33 changes: 19 additions & 14 deletions datapath/tunnel.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,32 +701,34 @@ static bool check_mtu(struct sk_buff *skb,
return true;
}

static struct rtable *find_route(const struct tnl_mutable_config *mutable,
__be32 saddr, __be32 daddr, u8 ipproto,
u8 tos)
static struct rtable *find_route(struct net *net,
__be32 *saddr, __be32 daddr, u8 ipproto,
u8 tos)
{
struct rtable *rt;
/* Tunnel configuration keeps DSCP part of TOS bits, But Linux
* router expect RT_TOS bits only. */

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
struct flowi fl = { .nl_u = { .ip4_u = {
.daddr = daddr,
.saddr = saddr,
.saddr = *saddr,
.tos = RT_TOS(tos) } },
.proto = ipproto };
struct rtable *rt;

if (unlikely(ip_route_output_key(port_key_get_net(&mutable->key), &rt, &fl)))
if (unlikely(ip_route_output_key(net, &rt, &fl)))
return ERR_PTR(-EADDRNOTAVAIL);

*saddr = fl.nl_u.ip4_u.saddr;
return rt;
#else
struct flowi4 fl = { .daddr = daddr,
.saddr = saddr,
.saddr = *saddr,
.flowi4_tos = RT_TOS(tos),
.flowi4_proto = ipproto };

return ip_route_output_key(port_key_get_net(&mutable->key), &fl);
rt = ip_route_output_key(net, &fl);
*saddr = fl.saddr;
return rt;
#endif
}

Expand Down Expand Up @@ -946,7 +948,8 @@ int ovs_tnl_send(struct vport *vport, struct sk_buff *skb)
}

/* Route lookup */
rt = find_route(mutable, saddr, daddr, tnl_vport->tnl_ops->ipproto, tos);
rt = find_route(port_key_get_net(&mutable->key), &saddr, daddr,
tnl_vport->tnl_ops->ipproto, tos);
if (IS_ERR(rt))
goto error_free;

Expand Down Expand Up @@ -999,8 +1002,8 @@ int ovs_tnl_send(struct vport *vport, struct sk_buff *skb)
iph->version = 4;
iph->ihl = sizeof(struct iphdr) >> 2;
iph->protocol = tnl_vport->tnl_ops->ipproto;
iph->daddr = rt->rt_dst;
iph->saddr = rt->rt_src;
iph->daddr = daddr;
iph->saddr = saddr;
iph->tos = tos;
iph->ttl = ttl;
iph->frag_off = frag_off;
Expand Down Expand Up @@ -1101,9 +1104,11 @@ static int tnl_set_config(struct net *net, struct nlattr *options,
if (ipv4_is_multicast(mutable->key.daddr)) {
struct net_device *dev;
struct rtable *rt;
__be32 saddr = mutable->key.saddr;

rt = find_route(mutable, mutable->key.saddr, mutable->key.daddr,
tnl_ops->ipproto, mutable->tos);
rt = find_route(port_key_get_net(&mutable->key),
&saddr, mutable->key.daddr,
tnl_ops->ipproto, mutable->tos);
if (IS_ERR(rt))
return -EADDRNOTAVAIL;
dev = rt_dst(rt).dev;
Expand Down

0 comments on commit 70cf679

Please sign in to comment.