1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#ifndef __NET_ROUTE_H_WRAPPER
#define __NET_ROUTE_H_WRAPPER
#include_next <net/route.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,39)
struct flowi_common {
int flowic_oif;
__u32 flowic_mark;
__u8 flowic_tos;
__u8 flowic_proto;
};
union flowi_uli {
struct {
__be16 dport;
__be16 sport;
} ports;
struct {
__u8 type;
__u8 code;
} icmpt;
struct {
__le16 dport;
__le16 sport;
} dnports;
__be32 spi;
__be32 gre_key;
struct {
__u8 type;
} mht;
};
struct flowi4 {
struct flowi_common __fl_common;
#define flowi4_oif __fl_common.flowic_oif
#define flowi4_iif __fl_common.flowic_iif
#define flowi4_mark __fl_common.flowic_mark
#define flowi4_tos __fl_common.flowic_tos
#define flowi4_scope __fl_common.flowic_scope
#define flowi4_proto __fl_common.flowic_proto
#define flowi4_flags __fl_common.flowic_flags
#define flowi4_secid __fl_common.flowic_secid
#define flowi4_tun_key __fl_common.flowic_tun_key
union flowi_uli uli;
#define fl4_gre_key uli.gre_key
/* (saddr,daddr) must be grouped, same order as in IP header */
__be32 saddr;
__be32 daddr;
} __attribute__((__aligned__(BITS_PER_LONG/8)));
struct flowi6 {
struct flowi_common __fl_common;
#define flowi6_oif __fl_common.flowic_oif
#define flowi6_iif __fl_common.flowic_iif
#define flowi6_mark __fl_common.flowic_mark
#define flowi6_tos __fl_common.flowic_tos
#define flowi6_scope __fl_common.flowic_scope
#define flowi6_proto __fl_common.flowic_proto
#define flowi6_flags __fl_common.flowic_flags
#define flowi6_secid __fl_common.flowic_secid
#define flowi6_tun_key __fl_common.flowic_tun_key
struct in6_addr daddr;
struct in6_addr saddr;
__be32 flowlabel;
union flowi_uli uli;
#define fl6_sport uli.ports.sport
#define fl6_dport uli.ports.dport
#define fl6_icmp_type uli.icmpt.type
#define fl6_icmp_code uli.icmpt.code
#define fl6_ipsec_spi uli.spi
#define fl6_mh_type uli.mht.type
#define fl6_gre_key uli.gre_key
} __attribute__((__aligned__(BITS_PER_LONG/8)));
static inline struct rtable *rpl_ip_route_output_key(struct net *net, struct flowi4 *flp)
{
struct rtable *rt;
/* Tunnel configuration keeps DSCP part of TOS bits, But Linux
* router expect RT_TOS bits only.
*/
struct flowi fl = { .nl_u = { .ip4_u = {
.daddr = flp->daddr,
.saddr = flp->saddr,
.tos = RT_TOS(flp->flowi4_tos) } },
.mark = flp->flowi4_mark,
.proto = flp->flowi4_proto };
if (unlikely(ip_route_output_key(net, &rt, &fl)))
return ERR_PTR(-EADDRNOTAVAIL);
flp->saddr = fl.nl_u.ip4_u.saddr;
return rt;
}
#define ip_route_output_key rpl_ip_route_output_key
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,38)
static inline int ip4_dst_hoplimit(const struct dst_entry *dst)
{
return dst_metric(dst, RTAX_HOPLIMIT);
}
#endif
#endif
|