aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_semantics.c
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-08-13 16:59:06 -0400
committerDavid S. Miller <davem@davemloft.net>2015-08-14 01:43:21 -0400
commit021dd3b8a142d482cb65a27bf6644e3764001460 (patch)
treefcf56a8999e3fe9f5f6a8dc4ea55c0cb734c1d1d /net/ipv4/fib_semantics.c
parent30bbaa19500559d7625c65632195413f639b3b97 (diff)
net: Add routes to the table associated with the device
When a device associated with a VRF is brought up or down routes should be added to/removed from the table associated with the VRF. fib_magic defaults to using the main or local tables. Have it use the table with the device if there is one. A part of this is directing prefsrc validations to the correct table as well. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_semantics.c')
-rw-r--r--net/ipv4/fib_semantics.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index 410ddb67221e..85e9a8abf15c 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -838,6 +838,23 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
838 return nh->nh_saddr; 838 return nh->nh_saddr;
839} 839}
840 840
841static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc)
842{
843 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst ||
844 fib_prefsrc != cfg->fc_dst) {
845 int tb_id = cfg->fc_table;
846
847 if (tb_id == RT_TABLE_MAIN)
848 tb_id = RT_TABLE_LOCAL;
849
850 if (inet_addr_type_table(cfg->fc_nlinfo.nl_net,
851 fib_prefsrc, tb_id) != RTN_LOCAL) {
852 return false;
853 }
854 }
855 return true;
856}
857
841struct fib_info *fib_create_info(struct fib_config *cfg) 858struct fib_info *fib_create_info(struct fib_config *cfg)
842{ 859{
843 int err; 860 int err;
@@ -1033,12 +1050,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
1033 fi->fib_flags |= RTNH_F_LINKDOWN; 1050 fi->fib_flags |= RTNH_F_LINKDOWN;
1034 } 1051 }
1035 1052
1036 if (fi->fib_prefsrc) { 1053 if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc))
1037 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || 1054 goto err_inval;
1038 fi->fib_prefsrc != cfg->fc_dst)
1039 if (inet_addr_type(net, fi->fib_prefsrc) != RTN_LOCAL)
1040 goto err_inval;
1041 }
1042 1055
1043 change_nexthops(fi) { 1056 change_nexthops(fi) {
1044 fib_info_update_nh_saddr(net, nexthop_nh); 1057 fib_info_update_nh_saddr(net, nexthop_nh);