1 #ifndef _NET_IP6_ROUTE_H
2 #define _NET_IP6_ROUTE_H
8 #if defined(__BIG_ENDIAN_BITFIELD)
12 #elif defined(__LITTLE_ENDIAN_BITFIELD)
18 __u8 prefix
[0]; /* 0,8 or 16 */
22 #include <net/ip6_fib.h>
25 #include <linux/ipv6.h>
26 #include <linux/route.h>
28 #define RT6_LOOKUP_F_IFACE 0x00000001
29 #define RT6_LOOKUP_F_REACHABLE 0x00000002
30 #define RT6_LOOKUP_F_HAS_SADDR 0x00000004
31 #define RT6_LOOKUP_F_SRCPREF_TMP 0x00000008
32 #define RT6_LOOKUP_F_SRCPREF_PUBLIC 0x00000010
33 #define RT6_LOOKUP_F_SRCPREF_COA 0x00000020
35 /* We do not (yet ?) support IPv6 jumbograms (RFC 2675)
36 * Unlike IPv4, hdr->seg_len doesn't include the IPv6 header
38 #define IP6_MAX_MTU (0xFFFF + sizeof(struct ipv6hdr))
41 * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
42 * between IPV6_ADDR_PREFERENCES socket option values
43 * IPV6_PREFER_SRC_TMP = 0x1
44 * IPV6_PREFER_SRC_PUBLIC = 0x2
45 * IPV6_PREFER_SRC_COA = 0x4
46 * and above RT6_LOOKUP_F_SRCPREF_xxx flags.
48 static inline int rt6_srcprefs2flags(unsigned int srcprefs
)
50 /* No need to bitmask because srcprefs have only 3 bits. */
54 static inline unsigned int rt6_flags2srcprefs(int flags
)
56 return (flags
>> 3) & 7;
59 extern void rt6_bind_peer(struct rt6_info
*rt
, int create
);
61 static inline struct inet_peer
*__rt6_get_peer(struct rt6_info
*rt
, int create
)
64 return rt6_peer_ptr(rt
);
66 rt6_bind_peer(rt
, create
);
67 return (rt6_has_peer(rt
) ? rt6_peer_ptr(rt
) : NULL
);
70 static inline struct inet_peer
*rt6_get_peer(struct rt6_info
*rt
)
72 return __rt6_get_peer(rt
, 0);
75 static inline struct inet_peer
*rt6_get_peer_create(struct rt6_info
*rt
)
77 return __rt6_get_peer(rt
, 1);
80 extern void ip6_route_input(struct sk_buff
*skb
);
82 extern struct dst_entry
* ip6_route_output(struct net
*net
,
83 const struct sock
*sk
,
85 extern struct dst_entry
* ip6_route_lookup(struct net
*net
,
86 struct flowi6
*fl6
, int flags
);
88 extern int ip6_route_init(void);
89 extern void ip6_route_cleanup(void);
91 extern int ipv6_route_ioctl(struct net
*net
,
95 extern int ip6_route_add(struct fib6_config
*cfg
);
96 extern int ip6_ins_rt(struct rt6_info
*);
97 extern int ip6_del_rt(struct rt6_info
*);
99 extern int ip6_route_get_saddr(struct net
*net
,
101 const struct in6_addr
*daddr
,
103 struct in6_addr
*saddr
);
105 extern struct rt6_info
*rt6_lookup(struct net
*net
,
106 const struct in6_addr
*daddr
,
107 const struct in6_addr
*saddr
,
110 extern struct dst_entry
*icmp6_dst_alloc(struct net_device
*dev
,
112 extern int icmp6_dst_gc(void);
114 extern void fib6_force_start_gc(struct net
*net
);
116 extern struct rt6_info
*addrconf_dst_alloc(struct inet6_dev
*idev
,
117 const struct in6_addr
*addr
,
121 * support functions for ND
124 extern struct rt6_info
* rt6_get_dflt_router(const struct in6_addr
*addr
,
125 struct net_device
*dev
);
126 extern struct rt6_info
* rt6_add_dflt_router(const struct in6_addr
*gwaddr
,
127 struct net_device
*dev
,
130 extern void rt6_purge_dflt_routers(struct net
*net
);
132 extern int rt6_route_rcv(struct net_device
*dev
,
134 const struct in6_addr
*gwaddr
);
136 extern void ip6_update_pmtu(struct sk_buff
*skb
, struct net
*net
, __be32 mtu
,
138 extern void ip6_sk_update_pmtu(struct sk_buff
*skb
, struct sock
*sk
,
140 extern void ip6_redirect(struct sk_buff
*skb
, struct net
*net
, int oif
, u32 mark
);
141 extern void ip6_redirect_no_header(struct sk_buff
*skb
, struct net
*net
, int oif
,
143 extern void ip6_sk_redirect(struct sk_buff
*skb
, struct sock
*sk
);
145 struct netlink_callback
;
147 struct rt6_rtnl_dump_arg
{
149 struct netlink_callback
*cb
;
153 extern int rt6_dump_route(struct rt6_info
*rt
, void *p_arg
);
154 extern void rt6_ifdown(struct net
*net
, struct net_device
*dev
);
155 extern void rt6_mtu_change(struct net_device
*dev
, unsigned int mtu
);
156 extern void rt6_remove_prefsrc(struct inet6_ifaddr
*ifp
);
160 * Store a destination cache entry in a socket
162 static inline void __ip6_dst_store(struct sock
*sk
, struct dst_entry
*dst
,
163 const struct in6_addr
*daddr
,
164 const struct in6_addr
*saddr
)
166 struct ipv6_pinfo
*np
= inet6_sk(sk
);
167 struct rt6_info
*rt
= (struct rt6_info
*) dst
;
169 sk_setup_caps(sk
, dst
);
170 np
->daddr_cache
= daddr
;
171 #ifdef CONFIG_IPV6_SUBTREES
172 np
->saddr_cache
= saddr
;
174 np
->dst_cookie
= rt
->rt6i_node
? rt
->rt6i_node
->fn_sernum
: 0;
177 static inline void ip6_dst_store(struct sock
*sk
, struct dst_entry
*dst
,
178 struct in6_addr
*daddr
, struct in6_addr
*saddr
)
180 spin_lock(&sk
->sk_dst_lock
);
181 __ip6_dst_store(sk
, dst
, daddr
, saddr
);
182 spin_unlock(&sk
->sk_dst_lock
);
185 static inline bool ipv6_unicast_destination(const struct sk_buff
*skb
)
187 struct rt6_info
*rt
= (struct rt6_info
*) skb_dst(skb
);
189 return rt
->rt6i_flags
& RTF_LOCAL
;
192 int ip6_fragment(struct sk_buff
*skb
, int (*output
)(struct sk_buff
*));
194 static inline int ip6_skb_dst_mtu(struct sk_buff
*skb
)
196 struct ipv6_pinfo
*np
= skb
->sk
? inet6_sk(skb
->sk
) : NULL
;
198 return (np
&& np
->pmtudisc
== IPV6_PMTUDISC_PROBE
) ?
199 skb_dst(skb
)->dev
->mtu
: dst_mtu(skb_dst(skb
));
202 static inline struct in6_addr
*rt6_nexthop(struct rt6_info
*rt
)
204 return &rt
->rt6i_gateway
;