route.h (eff430de53be6f3328c3eebe93755f1ecf499e37) | route.h (b71d1d426d263b0b6cb5760322efebbfc89d4463) |
---|---|
1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Definitions for the IP router. 7 * 8 * Version: @(#)route.h 1.0.4 05/27/93 --- 136 unchanged lines hidden (view full) --- 145 return ip_route_output_key(net, &fl4); 146} 147 148static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk, 149 __be32 daddr, __be32 saddr, 150 __be16 dport, __be16 sport, 151 __u8 proto, __u8 tos, int oif) 152{ | 1/* 2 * INET An implementation of the TCP/IP protocol suite for the LINUX 3 * operating system. INET is implemented using the BSD Socket 4 * interface as the means of communication with the user level. 5 * 6 * Definitions for the IP router. 7 * 8 * Version: @(#)route.h 1.0.4 05/27/93 --- 136 unchanged lines hidden (view full) --- 145 return ip_route_output_key(net, &fl4); 146} 147 148static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk, 149 __be32 daddr, __be32 saddr, 150 __be16 dport, __be16 sport, 151 __u8 proto, __u8 tos, int oif) 152{ |
153 struct flowi4 fl4 = { 154 .flowi4_oif = oif, 155 .flowi4_flags = sk ? inet_sk_flowi_flags(sk) : 0, 156 .flowi4_mark = sk ? sk->sk_mark : 0, 157 .daddr = daddr, 158 .saddr = saddr, 159 .flowi4_tos = tos, 160 .flowi4_proto = proto, 161 .fl4_dport = dport, 162 .fl4_sport = sport, 163 }; | 153 struct flowi4 fl4; 154 155 flowi4_init_output(&fl4, oif, sk ? sk->sk_mark : 0, tos, 156 RT_SCOPE_UNIVERSE, proto, 157 sk ? inet_sk_flowi_flags(sk) : 0, 158 daddr, saddr, dport, sport); |
164 if (sk) 165 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 166 return ip_route_output_flow(net, &fl4, sk); 167} 168 169static inline struct rtable *ip_route_output_gre(struct net *net, 170 __be32 daddr, __be32 saddr, 171 __be32 gre_key, __u8 tos, int oif) --- 19 unchanged lines hidden (view full) --- 191} 192 193static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, 194 u8 tos, struct net_device *devin) 195{ 196 return ip_route_input_common(skb, dst, src, tos, devin, true); 197} 198 | 159 if (sk) 160 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 161 return ip_route_output_flow(net, &fl4, sk); 162} 163 164static inline struct rtable *ip_route_output_gre(struct net *net, 165 __be32 daddr, __be32 saddr, 166 __be32 gre_key, __u8 tos, int oif) --- 19 unchanged lines hidden (view full) --- 186} 187 188static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, 189 u8 tos, struct net_device *devin) 190{ 191 return ip_route_input_common(skb, dst, src, tos, devin, true); 192} 193 |
199extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev); | 194extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, 195 unsigned short new_mtu, struct net_device *dev); |
200extern void ip_rt_send_redirect(struct sk_buff *skb); 201 202extern unsigned inet_addr_type(struct net *net, __be32 addr); 203extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); 204extern void ip_rt_multicast_event(struct in_device *); 205extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); 206extern void ip_rt_get_source(u8 *src, struct rtable *rt); 207extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); --- 17 unchanged lines hidden (view full) --- 225 return ip_tos2prio[IPTOS_TOS(tos)>>1]; 226} 227 228static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos, 229 int oif, u8 protocol, 230 __be16 sport, __be16 dport, 231 struct sock *sk, bool can_sleep) 232{ | 196extern void ip_rt_send_redirect(struct sk_buff *skb); 197 198extern unsigned inet_addr_type(struct net *net, __be32 addr); 199extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); 200extern void ip_rt_multicast_event(struct in_device *); 201extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); 202extern void ip_rt_get_source(u8 *src, struct rtable *rt); 203extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); --- 17 unchanged lines hidden (view full) --- 221 return ip_tos2prio[IPTOS_TOS(tos)>>1]; 222} 223 224static inline struct rtable *ip_route_connect(__be32 dst, __be32 src, u32 tos, 225 int oif, u8 protocol, 226 __be16 sport, __be16 dport, 227 struct sock *sk, bool can_sleep) 228{ |
233 struct flowi4 fl4 = { 234 .flowi4_oif = oif, 235 .flowi4_mark = sk->sk_mark, 236 .daddr = dst, 237 .saddr = src, 238 .flowi4_tos = tos, 239 .flowi4_proto = protocol, 240 .fl4_sport = sport, 241 .fl4_dport = dport, 242 }; | |
243 struct net *net = sock_net(sk); 244 struct rtable *rt; | 229 struct net *net = sock_net(sk); 230 struct rtable *rt; |
231 struct flowi4 fl4; 232 __u8 flow_flags; |
|
245 | 233 |
234 flow_flags = 0; |
|
246 if (inet_sk(sk)->transparent) | 235 if (inet_sk(sk)->transparent) |
247 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC; | 236 flow_flags |= FLOWI_FLAG_ANYSRC; |
248 if (protocol == IPPROTO_TCP) | 237 if (protocol == IPPROTO_TCP) |
249 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS; | 238 flow_flags |= FLOWI_FLAG_PRECOW_METRICS; |
250 if (can_sleep) | 239 if (can_sleep) |
251 fl4.flowi4_flags |= FLOWI_FLAG_CAN_SLEEP; | 240 flow_flags |= FLOWI_FLAG_CAN_SLEEP; |
252 | 241 |
242 flowi4_init_output(&fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, 243 protocol, flow_flags, dst, src, dport, sport); 244 |
|
253 if (!dst || !src) { 254 rt = __ip_route_output_key(net, &fl4); 255 if (IS_ERR(rt)) 256 return rt; 257 fl4.daddr = rt->rt_dst; 258 fl4.saddr = rt->rt_src; 259 ip_rt_put(rt); 260 } 261 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 262 return ip_route_output_flow(net, &fl4, sk); 263} 264 265static inline struct rtable *ip_route_newports(struct rtable *rt, 266 u8 protocol, __be16 orig_sport, 267 __be16 orig_dport, __be16 sport, 268 __be16 dport, struct sock *sk) 269{ 270 if (sport != orig_sport || dport != orig_dport) { | 245 if (!dst || !src) { 246 rt = __ip_route_output_key(net, &fl4); 247 if (IS_ERR(rt)) 248 return rt; 249 fl4.daddr = rt->rt_dst; 250 fl4.saddr = rt->rt_src; 251 ip_rt_put(rt); 252 } 253 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 254 return ip_route_output_flow(net, &fl4, sk); 255} 256 257static inline struct rtable *ip_route_newports(struct rtable *rt, 258 u8 protocol, __be16 orig_sport, 259 __be16 orig_dport, __be16 sport, 260 __be16 dport, struct sock *sk) 261{ 262 if (sport != orig_sport || dport != orig_dport) { |
271 struct flowi4 fl4 = { 272 .flowi4_oif = rt->rt_oif, 273 .flowi4_mark = rt->rt_mark, 274 .daddr = rt->rt_dst, 275 .saddr = rt->rt_src, 276 .flowi4_tos = rt->rt_tos, 277 .flowi4_proto = protocol, 278 .fl4_sport = sport, 279 .fl4_dport = dport 280 }; | 263 struct flowi4 fl4; 264 __u8 flow_flags; 265 266 flow_flags = 0; |
281 if (inet_sk(sk)->transparent) | 267 if (inet_sk(sk)->transparent) |
282 fl4.flowi4_flags |= FLOWI_FLAG_ANYSRC; | 268 flow_flags |= FLOWI_FLAG_ANYSRC; |
283 if (protocol == IPPROTO_TCP) | 269 if (protocol == IPPROTO_TCP) |
284 fl4.flowi4_flags |= FLOWI_FLAG_PRECOW_METRICS; | 270 flow_flags |= FLOWI_FLAG_PRECOW_METRICS; 271 flowi4_init_output(&fl4, rt->rt_oif, rt->rt_mark, rt->rt_tos, 272 RT_SCOPE_UNIVERSE, protocol, flow_flags, 273 rt->rt_dst, rt->rt_src, dport, sport); |
285 ip_rt_put(rt); 286 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 287 return ip_route_output_flow(sock_net(sk), &fl4, sk); 288 } 289 return rt; 290} 291 292extern void rt_bind_peer(struct rtable *rt, int create); --- 27 unchanged lines hidden --- | 274 ip_rt_put(rt); 275 security_sk_classify_flow(sk, flowi4_to_flowi(&fl4)); 276 return ip_route_output_flow(sock_net(sk), &fl4, sk); 277 } 278 return rt; 279} 280 281extern void rt_bind_peer(struct rtable *rt, int create); --- 27 unchanged lines hidden --- |