diff options
author | David S. Miller <davem@davemloft.net> | 2011-03-12 00:00:52 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-03-12 18:08:42 -0500 |
commit | 78fbfd8a653ca972afe479517a40661bfff6d8c3 (patch) | |
tree | 9dccc5c16bf269d53d8499064ec95a998e84c646 /include/net/route.h | |
parent | 1561747ddf9d28185548687b11aae7074d6129c4 (diff) |
ipv4: Create and use route lookup helpers.
The idea here is this minimizes the number of places one has to edit
in order to make changes to how flows are defined and used.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/route.h')
-rw-r--r-- | include/net/route.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/include/net/route.h b/include/net/route.h index 9257f5f17337..f140f4130fea 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -132,6 +132,54 @@ static inline struct rtable *ip_route_output_key(struct net *net, struct flowi * | |||
132 | return ip_route_output_flow(net, flp, NULL); | 132 | return ip_route_output_flow(net, flp, NULL); |
133 | } | 133 | } |
134 | 134 | ||
135 | static inline struct rtable *ip_route_output(struct net *net, __be32 daddr, | ||
136 | __be32 saddr, u8 tos, int oif) | ||
137 | { | ||
138 | struct flowi fl = { | ||
139 | .oif = oif, | ||
140 | .fl4_dst = daddr, | ||
141 | .fl4_src = saddr, | ||
142 | .fl4_tos = tos, | ||
143 | }; | ||
144 | return ip_route_output_key(net, &fl); | ||
145 | } | ||
146 | |||
147 | static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk, | ||
148 | __be32 daddr, __be32 saddr, | ||
149 | __be16 dport, __be16 sport, | ||
150 | __u8 proto, __u8 tos, int oif) | ||
151 | { | ||
152 | struct flowi fl = { | ||
153 | .oif = oif, | ||
154 | .flags = sk ? inet_sk_flowi_flags(sk) : 0, | ||
155 | .mark = sk ? sk->sk_mark : 0, | ||
156 | .fl4_dst = daddr, | ||
157 | .fl4_src = saddr, | ||
158 | .fl4_tos = tos, | ||
159 | .proto = proto, | ||
160 | .fl_ip_dport = dport, | ||
161 | .fl_ip_sport = sport, | ||
162 | }; | ||
163 | if (sk) | ||
164 | security_sk_classify_flow(sk, &fl); | ||
165 | return ip_route_output_flow(net, &fl, sk); | ||
166 | } | ||
167 | |||
168 | static inline struct rtable *ip_route_output_gre(struct net *net, | ||
169 | __be32 daddr, __be32 saddr, | ||
170 | __be32 gre_key, __u8 tos, int oif) | ||
171 | { | ||
172 | struct flowi fl = { | ||
173 | .oif = oif, | ||
174 | .fl4_dst = daddr, | ||
175 | .fl4_src = saddr, | ||
176 | .fl4_tos = tos, | ||
177 | .proto = IPPROTO_GRE, | ||
178 | .fl_gre_key = gre_key, | ||
179 | }; | ||
180 | return ip_route_output_key(net, &fl); | ||
181 | } | ||
182 | |||
135 | extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, | 183 | extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, |
136 | u8 tos, struct net_device *devin, bool noref); | 184 | u8 tos, struct net_device *devin, bool noref); |
137 | 185 | ||