aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2010-07-20 18:03:14 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-22 16:46:21 -0400
commit963bfeeeec913d135c15dc400f2f86cb62655d81 (patch)
tree73a5117b91580637df8c5c7e21ff40656eb93904 /net
parente955cead031177b083fbf18d04a03c06e330a439 (diff)
net: RTA_MARK addition
Add a new rt attribute, RTA_MARK, and use it in rt_fill_info()/inet_rtm_getroute() to support following commands : ip route get 192.168.20.110 mark NUMBER ip route get 192.168.20.108 from 192.168.20.110 iif eth1 mark NUMBER ip route list cache [192.168.20.110] mark NUMBER Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/route.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 562ce92de2a6..3f56b6e6c6aa 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2878,6 +2878,9 @@ static int rt_fill_info(struct net *net,
2878 if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0) 2878 if (rtnetlink_put_metrics(skb, rt->dst.metrics) < 0)
2879 goto nla_put_failure; 2879 goto nla_put_failure;
2880 2880
2881 if (rt->fl.mark)
2882 NLA_PUT_BE32(skb, RTA_MARK, rt->fl.mark);
2883
2881 error = rt->dst.error; 2884 error = rt->dst.error;
2882 expires = rt->dst.expires ? rt->dst.expires - jiffies : 0; 2885 expires = rt->dst.expires ? rt->dst.expires - jiffies : 0;
2883 if (rt->peer) { 2886 if (rt->peer) {
@@ -2933,6 +2936,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2933 __be32 src = 0; 2936 __be32 src = 0;
2934 u32 iif; 2937 u32 iif;
2935 int err; 2938 int err;
2939 int mark;
2936 struct sk_buff *skb; 2940 struct sk_buff *skb;
2937 2941
2938 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy); 2942 err = nlmsg_parse(nlh, sizeof(*rtm), tb, RTA_MAX, rtm_ipv4_policy);
@@ -2960,6 +2964,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2960 src = tb[RTA_SRC] ? nla_get_be32(tb[RTA_SRC]) : 0; 2964 src = tb[RTA_SRC] ? nla_get_be32(tb[RTA_SRC]) : 0;
2961 dst = tb[RTA_DST] ? nla_get_be32(tb[RTA_DST]) : 0; 2965 dst = tb[RTA_DST] ? nla_get_be32(tb[RTA_DST]) : 0;
2962 iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0; 2966 iif = tb[RTA_IIF] ? nla_get_u32(tb[RTA_IIF]) : 0;
2967 mark = tb[RTA_MARK] ? nla_get_u32(tb[RTA_MARK]) : 0;
2963 2968
2964 if (iif) { 2969 if (iif) {
2965 struct net_device *dev; 2970 struct net_device *dev;
@@ -2972,6 +2977,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2972 2977
2973 skb->protocol = htons(ETH_P_IP); 2978 skb->protocol = htons(ETH_P_IP);
2974 skb->dev = dev; 2979 skb->dev = dev;
2980 skb->mark = mark;
2975 local_bh_disable(); 2981 local_bh_disable();
2976 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev); 2982 err = ip_route_input(skb, dst, src, rtm->rtm_tos, dev);
2977 local_bh_enable(); 2983 local_bh_enable();
@@ -2989,6 +2995,7 @@ static int inet_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void
2989 }, 2995 },
2990 }, 2996 },
2991 .oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0, 2997 .oif = tb[RTA_OIF] ? nla_get_u32(tb[RTA_OIF]) : 0,
2998 .mark = mark,
2992 }; 2999 };
2993 err = ip_route_output_key(net, &rt, &fl); 3000 err = ip_route_output_key(net, &rt, &fl);
2994 } 3001 }