fib_semantics.c (f43dc23d5ea91fca257be02138a255f02d98e806) fib_semantics.c (c7066f70d9610df0b9406cc635fc09e86136e714)
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * IPv4 Forwarding Information Base: semantics.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 186 unchanged lines hidden (view full) ---

195
196 for_nexthops(fi) {
197 if (nh->nh_oif != onh->nh_oif ||
198 nh->nh_gw != onh->nh_gw ||
199 nh->nh_scope != onh->nh_scope ||
200#ifdef CONFIG_IP_ROUTE_MULTIPATH
201 nh->nh_weight != onh->nh_weight ||
202#endif
1/*
2 * INET An implementation of the TCP/IP protocol suite for the LINUX
3 * operating system. INET is implemented using the BSD Socket
4 * interface as the means of communication with the user level.
5 *
6 * IPv4 Forwarding Information Base: semantics.
7 *
8 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>

--- 186 unchanged lines hidden (view full) ---

195
196 for_nexthops(fi) {
197 if (nh->nh_oif != onh->nh_oif ||
198 nh->nh_gw != onh->nh_gw ||
199 nh->nh_scope != onh->nh_scope ||
200#ifdef CONFIG_IP_ROUTE_MULTIPATH
201 nh->nh_weight != onh->nh_weight ||
202#endif
203#ifdef CONFIG_NET_CLS_ROUTE
203#ifdef CONFIG_IP_ROUTE_CLASSID
204 nh->nh_tclassid != onh->nh_tclassid ||
205#endif
206 ((nh->nh_flags ^ onh->nh_flags) & ~RTNH_F_DEAD))
207 return -1;
208 onh++;
209 } endfor_nexthops(fi);
210 return 0;
211}

--- 205 unchanged lines hidden (view full) ---

417 nexthop_nh->nh_weight = rtnh->rtnh_hops + 1;
418
419 attrlen = rtnh_attrlen(rtnh);
420 if (attrlen > 0) {
421 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
422
423 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
424 nexthop_nh->nh_gw = nla ? nla_get_be32(nla) : 0;
204 nh->nh_tclassid != onh->nh_tclassid ||
205#endif
206 ((nh->nh_flags ^ onh->nh_flags) & ~RTNH_F_DEAD))
207 return -1;
208 onh++;
209 } endfor_nexthops(fi);
210 return 0;
211}

--- 205 unchanged lines hidden (view full) ---

417 nexthop_nh->nh_weight = rtnh->rtnh_hops + 1;
418
419 attrlen = rtnh_attrlen(rtnh);
420 if (attrlen > 0) {
421 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
422
423 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
424 nexthop_nh->nh_gw = nla ? nla_get_be32(nla) : 0;
425#ifdef CONFIG_NET_CLS_ROUTE
425#ifdef CONFIG_IP_ROUTE_CLASSID
426 nla = nla_find(attrs, attrlen, RTA_FLOW);
427 nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0;
428#endif
429 }
430
431 rtnh = rtnh_next(rtnh, &remaining);
432 } endfor_nexthops(fi);
433

--- 37 unchanged lines hidden (view full) ---

471
472 attrlen = rtnh_attrlen(rtnh);
473 if (attrlen < 0) {
474 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
475
476 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
477 if (nla && nla_get_be32(nla) != nh->nh_gw)
478 return 1;
426 nla = nla_find(attrs, attrlen, RTA_FLOW);
427 nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0;
428#endif
429 }
430
431 rtnh = rtnh_next(rtnh, &remaining);
432 } endfor_nexthops(fi);
433

--- 37 unchanged lines hidden (view full) ---

471
472 attrlen = rtnh_attrlen(rtnh);
473 if (attrlen < 0) {
474 struct nlattr *nla, *attrs = rtnh_attrs(rtnh);
475
476 nla = nla_find(attrs, attrlen, RTA_GATEWAY);
477 if (nla && nla_get_be32(nla) != nh->nh_gw)
478 return 1;
479#ifdef CONFIG_NET_CLS_ROUTE
479#ifdef CONFIG_IP_ROUTE_CLASSID
480 nla = nla_find(attrs, attrlen, RTA_FLOW);
481 if (nla && nla_get_u32(nla) != nh->nh_tclassid)
482 return 1;
483#endif
484 }
485
486 rtnh = rtnh_next(rtnh, &remaining);
487 } endfor_nexthops(fi);

--- 70 unchanged lines hidden (view full) ---

558 nh->nh_dev = dev;
559 dev_hold(dev);
560 nh->nh_scope = RT_SCOPE_LINK;
561 return 0;
562 }
563 rcu_read_lock();
564 {
565 struct flowi fl = {
480 nla = nla_find(attrs, attrlen, RTA_FLOW);
481 if (nla && nla_get_u32(nla) != nh->nh_tclassid)
482 return 1;
483#endif
484 }
485
486 rtnh = rtnh_next(rtnh, &remaining);
487 } endfor_nexthops(fi);

--- 70 unchanged lines hidden (view full) ---

558 nh->nh_dev = dev;
559 dev_hold(dev);
560 nh->nh_scope = RT_SCOPE_LINK;
561 return 0;
562 }
563 rcu_read_lock();
564 {
565 struct flowi fl = {
566 .fl4_dst = nh->nh_gw,
567 .fl4_scope = cfg->fc_scope + 1,
566 .nl_u = {
567 .ip4_u = {
568 .daddr = nh->nh_gw,
569 .scope = cfg->fc_scope + 1,
570 },
571 },
568 .oif = nh->nh_oif,
569 };
570
571 /* It is not necessary, but requires a bit of thinking */
572 if (fl.fl4_scope < RT_SCOPE_LINK)
573 fl.fl4_scope = RT_SCOPE_LINK;
574 err = fib_lookup(net, &fl, &res);
575 if (err) {

--- 198 unchanged lines hidden (view full) ---

774#ifdef CONFIG_IP_ROUTE_MULTIPATH
775 err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg);
776 if (err != 0)
777 goto failure;
778 if (cfg->fc_oif && fi->fib_nh->nh_oif != cfg->fc_oif)
779 goto err_inval;
780 if (cfg->fc_gw && fi->fib_nh->nh_gw != cfg->fc_gw)
781 goto err_inval;
572 .oif = nh->nh_oif,
573 };
574
575 /* It is not necessary, but requires a bit of thinking */
576 if (fl.fl4_scope < RT_SCOPE_LINK)
577 fl.fl4_scope = RT_SCOPE_LINK;
578 err = fib_lookup(net, &fl, &res);
579 if (err) {

--- 198 unchanged lines hidden (view full) ---

778#ifdef CONFIG_IP_ROUTE_MULTIPATH
779 err = fib_get_nhs(fi, cfg->fc_mp, cfg->fc_mp_len, cfg);
780 if (err != 0)
781 goto failure;
782 if (cfg->fc_oif && fi->fib_nh->nh_oif != cfg->fc_oif)
783 goto err_inval;
784 if (cfg->fc_gw && fi->fib_nh->nh_gw != cfg->fc_gw)
785 goto err_inval;
782#ifdef CONFIG_NET_CLS_ROUTE
786#ifdef CONFIG_IP_ROUTE_CLASSID
783 if (cfg->fc_flow && fi->fib_nh->nh_tclassid != cfg->fc_flow)
784 goto err_inval;
785#endif
786#else
787 goto err_inval;
788#endif
789 } else {
790 struct fib_nh *nh = fi->fib_nh;
791
792 nh->nh_oif = cfg->fc_oif;
793 nh->nh_gw = cfg->fc_gw;
794 nh->nh_flags = cfg->fc_flags;
787 if (cfg->fc_flow && fi->fib_nh->nh_tclassid != cfg->fc_flow)
788 goto err_inval;
789#endif
790#else
791 goto err_inval;
792#endif
793 } else {
794 struct fib_nh *nh = fi->fib_nh;
795
796 nh->nh_oif = cfg->fc_oif;
797 nh->nh_gw = cfg->fc_gw;
798 nh->nh_flags = cfg->fc_flags;
795#ifdef CONFIG_NET_CLS_ROUTE
799#ifdef CONFIG_IP_ROUTE_CLASSID
796 nh->nh_tclassid = cfg->fc_flow;
797#endif
798#ifdef CONFIG_IP_ROUTE_MULTIPATH
799 nh->nh_weight = 1;
800#endif
801 }
802
803 if (fib_props[cfg->fc_type].error) {

--- 193 unchanged lines hidden (view full) ---

997 NLA_PUT_BE32(skb, RTA_PREFSRC, fi->fib_prefsrc);
998
999 if (fi->fib_nhs == 1) {
1000 if (fi->fib_nh->nh_gw)
1001 NLA_PUT_BE32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw);
1002
1003 if (fi->fib_nh->nh_oif)
1004 NLA_PUT_U32(skb, RTA_OIF, fi->fib_nh->nh_oif);
800 nh->nh_tclassid = cfg->fc_flow;
801#endif
802#ifdef CONFIG_IP_ROUTE_MULTIPATH
803 nh->nh_weight = 1;
804#endif
805 }
806
807 if (fib_props[cfg->fc_type].error) {

--- 193 unchanged lines hidden (view full) ---

1001 NLA_PUT_BE32(skb, RTA_PREFSRC, fi->fib_prefsrc);
1002
1003 if (fi->fib_nhs == 1) {
1004 if (fi->fib_nh->nh_gw)
1005 NLA_PUT_BE32(skb, RTA_GATEWAY, fi->fib_nh->nh_gw);
1006
1007 if (fi->fib_nh->nh_oif)
1008 NLA_PUT_U32(skb, RTA_OIF, fi->fib_nh->nh_oif);
1005#ifdef CONFIG_NET_CLS_ROUTE
1009#ifdef CONFIG_IP_ROUTE_CLASSID
1006 if (fi->fib_nh[0].nh_tclassid)
1007 NLA_PUT_U32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid);
1008#endif
1009 }
1010#ifdef CONFIG_IP_ROUTE_MULTIPATH
1011 if (fi->fib_nhs > 1) {
1012 struct rtnexthop *rtnh;
1013 struct nlattr *mp;

--- 8 unchanged lines hidden (view full) ---

1022 goto nla_put_failure;
1023
1024 rtnh->rtnh_flags = nh->nh_flags & 0xFF;
1025 rtnh->rtnh_hops = nh->nh_weight - 1;
1026 rtnh->rtnh_ifindex = nh->nh_oif;
1027
1028 if (nh->nh_gw)
1029 NLA_PUT_BE32(skb, RTA_GATEWAY, nh->nh_gw);
1010 if (fi->fib_nh[0].nh_tclassid)
1011 NLA_PUT_U32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid);
1012#endif
1013 }
1014#ifdef CONFIG_IP_ROUTE_MULTIPATH
1015 if (fi->fib_nhs > 1) {
1016 struct rtnexthop *rtnh;
1017 struct nlattr *mp;

--- 8 unchanged lines hidden (view full) ---

1026 goto nla_put_failure;
1027
1028 rtnh->rtnh_flags = nh->nh_flags & 0xFF;
1029 rtnh->rtnh_hops = nh->nh_weight - 1;
1030 rtnh->rtnh_ifindex = nh->nh_oif;
1031
1032 if (nh->nh_gw)
1033 NLA_PUT_BE32(skb, RTA_GATEWAY, nh->nh_gw);
1030#ifdef CONFIG_NET_CLS_ROUTE
1034#ifdef CONFIG_IP_ROUTE_CLASSID
1031 if (nh->nh_tclassid)
1032 NLA_PUT_U32(skb, RTA_FLOW, nh->nh_tclassid);
1033#endif
1034 /* length of rtnetlink header + attributes */
1035 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh;
1036 } endfor_nexthops(fi);
1037
1038 nla_nest_end(skb, mp);

--- 202 unchanged lines hidden ---
1035 if (nh->nh_tclassid)
1036 NLA_PUT_U32(skb, RTA_FLOW, nh->nh_tclassid);
1037#endif
1038 /* length of rtnetlink header + attributes */
1039 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh;
1040 } endfor_nexthops(fi);
1041
1042 nla_nest_end(skb, mp);

--- 202 unchanged lines hidden ---