aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2011-03-12 02:02:42 -0500
committerDavid S. Miller <davem@davemloft.net>2011-03-12 18:08:49 -0500
commit9ade22861f922344788321e374c542c92bc049b6 (patch)
treec0bc23180b3f51104745d263a106c62b4bec11a4 /net/ipv4
parent9d6ec938019c6b16cb9ec96598ebe8f20de435fe (diff)
ipv4: Use flowi4 in FIB layer.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/fib_frontend.c40
-rw-r--r--net/ipv4/fib_rules.c7
-rw-r--r--net/ipv4/fib_semantics.c14
3 files changed, 31 insertions, 30 deletions
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
index 48125d559f17..a373a259253c 100644
--- a/net/ipv4/fib_frontend.c
+++ b/net/ipv4/fib_frontend.c
@@ -140,7 +140,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net,
140 const struct net_device *dev, 140 const struct net_device *dev,
141 __be32 addr) 141 __be32 addr)
142{ 142{
143 struct flowi fl = { .fl4_dst = addr }; 143 struct flowi4 fl4 = { .daddr = addr };
144 struct fib_result res; 144 struct fib_result res;
145 unsigned ret = RTN_BROADCAST; 145 unsigned ret = RTN_BROADCAST;
146 struct fib_table *local_table; 146 struct fib_table *local_table;
@@ -158,7 +158,7 @@ static inline unsigned __inet_dev_addr_type(struct net *net,
158 if (local_table) { 158 if (local_table) {
159 ret = RTN_UNICAST; 159 ret = RTN_UNICAST;
160 rcu_read_lock(); 160 rcu_read_lock();
161 if (!fib_table_lookup(local_table, &fl.u.ip4, &res, FIB_LOOKUP_NOREF)) { 161 if (!fib_table_lookup(local_table, &fl4, &res, FIB_LOOKUP_NOREF)) {
162 if (!dev || dev == res.fi->fib_dev) 162 if (!dev || dev == res.fi->fib_dev)
163 ret = res.type; 163 ret = res.type;
164 } 164 }
@@ -193,20 +193,20 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
193 u32 *itag, u32 mark) 193 u32 *itag, u32 mark)
194{ 194{
195 struct in_device *in_dev; 195 struct in_device *in_dev;
196 struct flowi fl; 196 struct flowi4 fl4;
197 struct fib_result res; 197 struct fib_result res;
198 int no_addr, rpf, accept_local; 198 int no_addr, rpf, accept_local;
199 bool dev_match; 199 bool dev_match;
200 int ret; 200 int ret;
201 struct net *net; 201 struct net *net;
202 202
203 fl.flowi_oif = 0; 203 fl4.flowi4_oif = 0;
204 fl.flowi_iif = oif; 204 fl4.flowi4_iif = oif;
205 fl.flowi_mark = mark; 205 fl4.flowi4_mark = mark;
206 fl.fl4_dst = src; 206 fl4.daddr = src;
207 fl.fl4_src = dst; 207 fl4.saddr = dst;
208 fl.fl4_tos = tos; 208 fl4.flowi4_tos = tos;
209 fl.fl4_scope = RT_SCOPE_UNIVERSE; 209 fl4.flowi4_scope = RT_SCOPE_UNIVERSE;
210 210
211 no_addr = rpf = accept_local = 0; 211 no_addr = rpf = accept_local = 0;
212 in_dev = __in_dev_get_rcu(dev); 212 in_dev = __in_dev_get_rcu(dev);
@@ -215,14 +215,14 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
215 rpf = IN_DEV_RPFILTER(in_dev); 215 rpf = IN_DEV_RPFILTER(in_dev);
216 accept_local = IN_DEV_ACCEPT_LOCAL(in_dev); 216 accept_local = IN_DEV_ACCEPT_LOCAL(in_dev);
217 if (mark && !IN_DEV_SRC_VMARK(in_dev)) 217 if (mark && !IN_DEV_SRC_VMARK(in_dev))
218 fl.flowi_mark = 0; 218 fl4.flowi4_mark = 0;
219 } 219 }
220 220
221 if (in_dev == NULL) 221 if (in_dev == NULL)
222 goto e_inval; 222 goto e_inval;
223 223
224 net = dev_net(dev); 224 net = dev_net(dev);
225 if (fib_lookup(net, &fl.u.ip4, &res)) 225 if (fib_lookup(net, &fl4, &res))
226 goto last_resort; 226 goto last_resort;
227 if (res.type != RTN_UNICAST) { 227 if (res.type != RTN_UNICAST) {
228 if (res.type != RTN_LOCAL || !accept_local) 228 if (res.type != RTN_LOCAL || !accept_local)
@@ -253,10 +253,10 @@ int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif,
253 goto last_resort; 253 goto last_resort;
254 if (rpf == 1) 254 if (rpf == 1)
255 goto e_rpf; 255 goto e_rpf;
256 fl.flowi_oif = dev->ifindex; 256 fl4.flowi4_oif = dev->ifindex;
257 257
258 ret = 0; 258 ret = 0;
259 if (fib_lookup(net, &fl.u.ip4, &res) == 0) { 259 if (fib_lookup(net, &fl4, &res) == 0) {
260 if (res.type == RTN_UNICAST) { 260 if (res.type == RTN_UNICAST) {
261 *spec_dst = FIB_RES_PREFSRC(res); 261 *spec_dst = FIB_RES_PREFSRC(res);
262 ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST; 262 ret = FIB_RES_NH(res).nh_scope >= RT_SCOPE_HOST;
@@ -796,11 +796,11 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
796{ 796{
797 797
798 struct fib_result res; 798 struct fib_result res;
799 struct flowi fl = { 799 struct flowi4 fl4 = {
800 .flowi_mark = frn->fl_mark, 800 .flowi4_mark = frn->fl_mark,
801 .fl4_dst = frn->fl_addr, 801 .daddr = frn->fl_addr,
802 .fl4_tos = frn->fl_tos, 802 .flowi4_tos = frn->fl_tos,
803 .fl4_scope = frn->fl_scope, 803 .flowi4_scope = frn->fl_scope,
804 }; 804 };
805 805
806#ifdef CONFIG_IP_MULTIPLE_TABLES 806#ifdef CONFIG_IP_MULTIPLE_TABLES
@@ -813,7 +813,7 @@ static void nl_fib_lookup(struct fib_result_nl *frn, struct fib_table *tb)
813 813
814 frn->tb_id = tb->tb_id; 814 frn->tb_id = tb->tb_id;
815 rcu_read_lock(); 815 rcu_read_lock();
816 frn->err = fib_table_lookup(tb, &fl.u.ip4, &res, FIB_LOOKUP_NOREF); 816 frn->err = fib_table_lookup(tb, &fl4, &res, FIB_LOOKUP_NOREF);
817 817
818 if (!frn->err) { 818 if (!frn->err) {
819 frn->prefixlen = res.prefixlen; 819 frn->prefixlen = res.prefixlen;
diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
index 0c63c4ab0936..a53bb1b5b118 100644
--- a/net/ipv4/fib_rules.c
+++ b/net/ipv4/fib_rules.c
@@ -106,14 +106,15 @@ errout:
106static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags) 106static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
107{ 107{
108 struct fib4_rule *r = (struct fib4_rule *) rule; 108 struct fib4_rule *r = (struct fib4_rule *) rule;
109 __be32 daddr = fl->fl4_dst; 109 struct flowi4 *fl4 = &fl->u.ip4;
110 __be32 saddr = fl->fl4_src; 110 __be32 daddr = fl4->daddr;
111 __be32 saddr = fl4->saddr;
111 112
112 if (((saddr ^ r->src) & r->srcmask) || 113 if (((saddr ^ r->src) & r->srcmask) ||
113 ((daddr ^ r->dst) & r->dstmask)) 114 ((daddr ^ r->dst) & r->dstmask))
114 return 0; 115 return 0;
115 116
116 if (r->tos && (r->tos != fl->fl4_tos)) 117 if (r->tos && (r->tos != fl4->flowi4_tos))
117 return 0; 118 return 0;
118 119
119 return 1; 120 return 1;
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index a721013fdf46..622ac4c95026 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -560,16 +560,16 @@ static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi,
560 } 560 }
561 rcu_read_lock(); 561 rcu_read_lock();
562 { 562 {
563 struct flowi fl = { 563 struct flowi4 fl4 = {
564 .fl4_dst = nh->nh_gw, 564 .daddr = nh->nh_gw,
565 .fl4_scope = cfg->fc_scope + 1, 565 .flowi4_scope = cfg->fc_scope + 1,
566 .flowi_oif = nh->nh_oif, 566 .flowi4_oif = nh->nh_oif,
567 }; 567 };
568 568
569 /* It is not necessary, but requires a bit of thinking */ 569 /* It is not necessary, but requires a bit of thinking */
570 if (fl.fl4_scope < RT_SCOPE_LINK) 570 if (fl4.flowi4_scope < RT_SCOPE_LINK)
571 fl.fl4_scope = RT_SCOPE_LINK; 571 fl4.flowi4_scope = RT_SCOPE_LINK;
572 err = fib_lookup(net, &fl.u.ip4, &res); 572 err = fib_lookup(net, &fl4, &res);
573 if (err) { 573 if (err) {
574 rcu_read_unlock(); 574 rcu_read_unlock();
575 return err; 575 return err;