summaryrefslogtreecommitdiffstats
path: root/include/net/route.h
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-12 00:00:52 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-12 15:08:42 -0800
commit78fbfd8a653ca972afe479517a40661bfff6d8c3 (patch)
tree9dccc5c16bf269d53d8499064ec95a998e84c646 /include/net/route.h
parent1561747ddf9d28185548687b11aae7074d6129c4 (diff)
downloadblackbird-op-linux-78fbfd8a653ca972afe479517a40661bfff6d8c3.tar.gz
blackbird-op-linux-78fbfd8a653ca972afe479517a40661bfff6d8c3.zip
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.h48
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 *
return ip_route_output_flow(net, flp, NULL);
}
+static inline struct rtable *ip_route_output(struct net *net, __be32 daddr,
+ __be32 saddr, u8 tos, int oif)
+{
+ struct flowi fl = {
+ .oif = oif,
+ .fl4_dst = daddr,
+ .fl4_src = saddr,
+ .fl4_tos = tos,
+ };
+ return ip_route_output_key(net, &fl);
+}
+
+static inline struct rtable *ip_route_output_ports(struct net *net, struct sock *sk,
+ __be32 daddr, __be32 saddr,
+ __be16 dport, __be16 sport,
+ __u8 proto, __u8 tos, int oif)
+{
+ struct flowi fl = {
+ .oif = oif,
+ .flags = sk ? inet_sk_flowi_flags(sk) : 0,
+ .mark = sk ? sk->sk_mark : 0,
+ .fl4_dst = daddr,
+ .fl4_src = saddr,
+ .fl4_tos = tos,
+ .proto = proto,
+ .fl_ip_dport = dport,
+ .fl_ip_sport = sport,
+ };
+ if (sk)
+ security_sk_classify_flow(sk, &fl);
+ return ip_route_output_flow(net, &fl, sk);
+}
+
+static inline struct rtable *ip_route_output_gre(struct net *net,
+ __be32 daddr, __be32 saddr,
+ __be32 gre_key, __u8 tos, int oif)
+{
+ struct flowi fl = {
+ .oif = oif,
+ .fl4_dst = daddr,
+ .fl4_src = saddr,
+ .fl4_tos = tos,
+ .proto = IPPROTO_GRE,
+ .fl_gre_key = gre_key,
+ };
+ return ip_route_output_key(net, &fl);
+}
+
extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src,
u8 tos, struct net_device *devin, bool noref);
OpenPOWER on IntegriCloud