Blame view

include/net/ip6_route.h 5.14 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef _NET_IP6_ROUTE_H
  #define _NET_IP6_ROUTE_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
  #define IP6_RT_PRIO_USER	1024
  #define IP6_RT_PRIO_ADDRCONF	256
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5

70ceb4f53   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
6
7
8
9
10
11
12
13
14
15
16
17
18
  struct route_info {
  	__u8			type;
  	__u8			length;
  	__u8			prefix_len;
  #if defined(__BIG_ENDIAN_BITFIELD)
  	__u8			reserved_h:3,
  				route_pref:2,
  				reserved_l:3;
  #elif defined(__LITTLE_ENDIAN_BITFIELD)
  	__u8			reserved_l:3,
  				route_pref:2,
  				reserved_h:3;
  #endif
e69a4adc6   Al Viro   [IPV6]: Misc endi...
19
  	__be32			lifetime;
70ceb4f53   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
20
21
  	__u8			prefix[0];	/* 0,8 or 16 */
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
24
  #include <net/flow.h>
  #include <net/ip6_fib.h>
  #include <net/sock.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
25
26
  #include <linux/ip.h>
  #include <linux/ipv6.h>
7cbca67c0   YOSHIFUJI Hideaki   [IPV6]: Support S...
27
28
29
30
31
32
  #define RT6_LOOKUP_F_IFACE		0x00000001
  #define RT6_LOOKUP_F_REACHABLE		0x00000002
  #define RT6_LOOKUP_F_HAS_SADDR		0x00000004
  #define RT6_LOOKUP_F_SRCPREF_TMP	0x00000008
  #define RT6_LOOKUP_F_SRCPREF_PUBLIC	0x00000010
  #define RT6_LOOKUP_F_SRCPREF_COA	0x00000020
77d16f450   YOSHIFUJI Hideaki   [IPV6] ROUTE: Uni...
33

0c9a2ac1f   YOSHIFUJI Hideaki / 吉藤英明   ipv6: Optmize tra...
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  /*
   * rt6_srcprefs2flags() and rt6_flags2srcprefs() translate
   * between IPV6_ADDR_PREFERENCES socket option values
   *	IPV6_PREFER_SRC_TMP    = 0x1
   *	IPV6_PREFER_SRC_PUBLIC = 0x2
   *	IPV6_PREFER_SRC_COA    = 0x4
   * and above RT6_LOOKUP_F_SRCPREF_xxx flags.
   */
  static inline int rt6_srcprefs2flags(unsigned int srcprefs)
  {
  	/* No need to bitmask because srcprefs have only 3 bits. */
  	return srcprefs << 3;
  }
  
  static inline unsigned int rt6_flags2srcprefs(int flags)
  {
  	return (flags >> 3) & 7;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
52

b34193638   David S. Miller   ipv6: Add infrast...
53
54
  extern void			rt6_bind_peer(struct rt6_info *rt,
  					      int create);
15c054251   David S. Miller   ipv6: Add rt6_get...
55
56
57
58
59
60
61
62
  static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt)
  {
  	if (rt->rt6i_peer)
  		return rt->rt6i_peer;
  
  	rt6_bind_peer(rt, 0);
  	return rt->rt6i_peer;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
63
  extern void			ip6_route_input(struct sk_buff *skb);
4591db4f3   Daniel Lezcano   [NETNS][IPV6] rou...
64
  extern struct dst_entry *	ip6_route_output(struct net *net,
9c7a4f9ce   Florian Westphal   ipv6: ip6_route_o...
65
  						 const struct sock *sk,
4c9483b2f   David S. Miller   ipv6: Convert to ...
66
  						 struct flowi6 *fl6);
ea6e574e3   Florian Westphal   ipv6: add ip6_rou...
67
68
  extern struct dst_entry *	ip6_route_lookup(struct net *net,
  						 struct flowi6 *fl6, int flags);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69

433d49c3b   Daniel Lezcano   [IPV6]: Make ip6_...
70
  extern int			ip6_route_init(void);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
  extern void			ip6_route_cleanup(void);
5578689a4   Daniel Lezcano   [NETNS][IPV6] rou...
72
73
74
  extern int			ipv6_route_ioctl(struct net *net,
  						 unsigned int cmd,
  						 void __user *arg);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
75

86872cb57   Thomas Graf   [IPv6] route: FIB...
76
  extern int			ip6_route_add(struct fib6_config *cfg);
40e22e8f3   Thomas Graf   [IPv6] route: Sim...
77
  extern int			ip6_ins_rt(struct rt6_info *);
e0a1ad73d   Thomas Graf   [IPv6] route: Sim...
78
  extern int			ip6_del_rt(struct rt6_info *);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
79

c3968a857   Daniel Walter   ipv6: RTA_PREFSRC...
80
81
  extern int			ip6_route_get_saddr(struct net *net,
  						    struct rt6_info *rt,
b71d1d426   Eric Dumazet   inet: constify ip...
82
  						    const struct in6_addr *daddr,
c3968a857   Daniel Walter   ipv6: RTA_PREFSRC...
83
84
  						    unsigned int prefs,
  						    struct in6_addr *saddr);
606a2b486   Daniel Lezcano   [NETNS][IPV6] rou...
85
  extern struct rt6_info		*rt6_lookup(struct net *net,
9acd9f3ae   YOSHIFUJI Hideaki   [IPV6]: Make addr...
86
87
  					    const struct in6_addr *daddr,
  					    const struct in6_addr *saddr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
  					    int oif, int flags);
3b00944c5   YOSHIFUJI Hideaki   [IPV6]: Make ndis...
89
  extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
90
  					 struct neighbour *neigh,
87a115783   David S. Miller   ipv6: Move xfrm_l...
91
  					 struct flowi6 *fl6);
3d0f24a74   Stephen Hemminger   ipv6: icmp6_dst_g...
92
  extern int icmp6_dst_gc(void);
3b00944c5   YOSHIFUJI Hideaki   [IPV6]: Make ndis...
93

63152fc0d   Daniel Lezcano   [NETNS][IPV6] ip6...
94
  extern void fib6_force_start_gc(struct net *net);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
95
96
97
  
  extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev,
  					   const struct in6_addr *addr,
8f0315190   David S. Miller   ipv6: Make third ...
98
  					   bool anycast);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99

6b75d0908   YOSHIFUJI Hideaki   [IPV6]: Optimize ...
100
  extern int			ip6_dst_hoplimit(struct dst_entry *dst);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
103
104
  /*
   *	support functions for ND
   *
   */
b71d1d426   Eric Dumazet   inet: constify ip...
105
  extern struct rt6_info *	rt6_get_dflt_router(const struct in6_addr *addr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
  						    struct net_device *dev);
b71d1d426   Eric Dumazet   inet: constify ip...
107
  extern struct rt6_info *	rt6_add_dflt_router(const struct in6_addr *gwaddr,
ebacaaa0f   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
108
109
  						    struct net_device *dev,
  						    unsigned int pref);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110

7b4da5322   Daniel Lezcano   [NETNS][IPV6] rou...
111
  extern void			rt6_purge_dflt_routers(struct net *net);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112

70ceb4f53   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
113
114
  extern int			rt6_route_rcv(struct net_device *dev,
  					      u8 *opt, int len,
b71d1d426   Eric Dumazet   inet: constify ip...
115
  					      const struct in6_addr *gwaddr);
70ceb4f53   YOSHIFUJI Hideaki   [IPV6]: ROUTE: Ad...
116

b71d1d426   Eric Dumazet   inet: constify ip...
117
118
119
  extern void			rt6_redirect(const struct in6_addr *dest,
  					     const struct in6_addr *src,
  					     const struct in6_addr *saddr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
120
121
122
  					     struct neighbour *neigh,
  					     u8 *lladdr,
  					     int on_link);
b71d1d426   Eric Dumazet   inet: constify ip...
123
124
  extern void			rt6_pmtu_discovery(const struct in6_addr *daddr,
  						   const struct in6_addr *saddr,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
126
  						   struct net_device *dev,
  						   u32 pmtu);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  struct netlink_callback;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128

fd2c3ef76   Eric Dumazet   net: cleanup incl...
129
  struct rt6_rtnl_dump_arg {
1b43af548   Patrick McHardy   [IPV6]: Increase ...
130
131
  	struct sk_buff *skb;
  	struct netlink_callback *cb;
191cd5825   Brian Haley   netns: Add networ...
132
  	struct net *net;
1b43af548   Patrick McHardy   [IPV6]: Increase ...
133
134
135
  };
  
  extern int rt6_dump_route(struct rt6_info *rt, void *p_arg);
f3db48517   Daniel Lezcano   [NETNS][IPV6] ip6...
136
  extern void rt6_ifdown(struct net *net, struct net_device *dev);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
137
  extern void rt6_mtu_change(struct net_device *dev, unsigned mtu);
c3968a857   Daniel Walter   ipv6: RTA_PREFSRC...
138
  extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
140
141
142
143
  
  /*
   *	Store a destination cache entry in a socket
   */
497c615ab   Herbert Xu   [IPV6]: Audit all...
144
  static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst,
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
145
  				   struct in6_addr *daddr, struct in6_addr *saddr)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
146
147
148
  {
  	struct ipv6_pinfo *np = inet6_sk(sk);
  	struct rt6_info *rt = (struct rt6_info *) dst;
f83ef8c0b   Herbert Xu   [IPV6]: Added GSO...
149
  	sk_setup_caps(sk, dst);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
150
  	np->daddr_cache = daddr;
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
151
152
153
  #ifdef CONFIG_IPV6_SUBTREES
  	np->saddr_cache = saddr;
  #endif
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
154
  	np->dst_cookie = rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
497c615ab   Herbert Xu   [IPV6]: Audit all...
155
156
157
  }
  
  static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst,
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
158
  				 struct in6_addr *daddr, struct in6_addr *saddr)
497c615ab   Herbert Xu   [IPV6]: Audit all...
159
  {
b6c6712a4   Eric Dumazet   net: sk_dst_cache...
160
  	spin_lock(&sk->sk_dst_lock);
8e1ef0a95   YOSHIFUJI Hideaki   [IPV6]: Cache sou...
161
  	__ip6_dst_store(sk, dst, daddr, saddr);
b6c6712a4   Eric Dumazet   net: sk_dst_cache...
162
  	spin_unlock(&sk->sk_dst_lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
163
164
165
166
  }
  
  static inline int ipv6_unicast_destination(struct sk_buff *skb)
  {
adf30907d   Eric Dumazet   net: skb->dst acc...
167
  	struct rt6_info *rt = (struct rt6_info *) skb_dst(skb);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
168
169
170
  
  	return rt->rt6i_flags & RTF_LOCAL;
  }
ad0081e43   David Stevens   ipv6: Fragment lo...
171
172
173
174
175
176
177
178
179
  int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *));
  
  static inline int ip6_skb_dst_mtu(struct sk_buff *skb)
  {
  	struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL;
  
  	return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ?
  	       skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb));
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
180
  #endif