fib_semantics.c (d033de5ceee8333e4fee3d59a956244d3736102a) | fib_semantics.c (127eb7cd3c210afead788991a30950a9e36759ea) |
---|---|
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> --- 28 unchanged lines hidden (view full) --- 37#include <net/ip.h> 38#include <net/protocol.h> 39#include <net/route.h> 40#include <net/tcp.h> 41#include <net/sock.h> 42#include <net/ip_fib.h> 43#include <net/netlink.h> 44#include <net/nexthop.h> | 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> --- 28 unchanged lines hidden (view full) --- 37#include <net/ip.h> 38#include <net/protocol.h> 39#include <net/route.h> 40#include <net/tcp.h> 41#include <net/sock.h> 42#include <net/ip_fib.h> 43#include <net/netlink.h> 44#include <net/nexthop.h> |
45#include <net/lwtunnel.h> |
|
45 46#include "fib_lookup.h" 47 48static DEFINE_SPINLOCK(fib_info_lock); 49static struct hlist_head *fib_info_hash; 50static struct hlist_head *fib_info_laddrhash; 51static unsigned int fib_info_hash_size; 52static unsigned int fib_info_cnt; --- 150 unchanged lines hidden (view full) --- 203/* Release a nexthop info record */ 204static void free_fib_info_rcu(struct rcu_head *head) 205{ 206 struct fib_info *fi = container_of(head, struct fib_info, rcu); 207 208 change_nexthops(fi) { 209 if (nexthop_nh->nh_dev) 210 dev_put(nexthop_nh->nh_dev); | 46 47#include "fib_lookup.h" 48 49static DEFINE_SPINLOCK(fib_info_lock); 50static struct hlist_head *fib_info_hash; 51static struct hlist_head *fib_info_laddrhash; 52static unsigned int fib_info_hash_size; 53static unsigned int fib_info_cnt; --- 150 unchanged lines hidden (view full) --- 204/* Release a nexthop info record */ 205static void free_fib_info_rcu(struct rcu_head *head) 206{ 207 struct fib_info *fi = container_of(head, struct fib_info, rcu); 208 209 change_nexthops(fi) { 210 if (nexthop_nh->nh_dev) 211 dev_put(nexthop_nh->nh_dev); |
212 lwtstate_put(nexthop_nh->nh_lwtstate); |
|
211 free_nh_exceptions(nexthop_nh); 212 rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output); 213 rt_fibinfo_free(&nexthop_nh->nh_rth_input); 214 } endfor_nexthops(fi); 215 216 if (fi->fib_metrics != (u32 *) dst_default_metrics) 217 kfree(fi->fib_metrics); 218 kfree(fi); --- 42 unchanged lines hidden (view full) --- 261 nh->nh_gw != onh->nh_gw || 262 nh->nh_scope != onh->nh_scope || 263#ifdef CONFIG_IP_ROUTE_MULTIPATH 264 nh->nh_weight != onh->nh_weight || 265#endif 266#ifdef CONFIG_IP_ROUTE_CLASSID 267 nh->nh_tclassid != onh->nh_tclassid || 268#endif | 213 free_nh_exceptions(nexthop_nh); 214 rt_fibinfo_free_cpus(nexthop_nh->nh_pcpu_rth_output); 215 rt_fibinfo_free(&nexthop_nh->nh_rth_input); 216 } endfor_nexthops(fi); 217 218 if (fi->fib_metrics != (u32 *) dst_default_metrics) 219 kfree(fi->fib_metrics); 220 kfree(fi); --- 42 unchanged lines hidden (view full) --- 263 nh->nh_gw != onh->nh_gw || 264 nh->nh_scope != onh->nh_scope || 265#ifdef CONFIG_IP_ROUTE_MULTIPATH 266 nh->nh_weight != onh->nh_weight || 267#endif 268#ifdef CONFIG_IP_ROUTE_CLASSID 269 nh->nh_tclassid != onh->nh_tclassid || 270#endif |
271 lwtunnel_cmp_encap(nh->nh_lwtstate, onh->nh_lwtstate) || |
|
269 ((nh->nh_flags ^ onh->nh_flags) & ~RTNH_COMPARE_MASK)) 270 return -1; 271 onh++; 272 } endfor_nexthops(fi); 273 return 0; 274} 275 276static inline unsigned int fib_devindex_hashfn(unsigned int val) --- 84 unchanged lines hidden (view full) --- 361 + nla_total_size(4) /* RTA_PRIORITY */ 362 + nla_total_size(4) /* RTA_PREFSRC */ 363 + nla_total_size(TCP_CA_NAME_MAX); /* RTAX_CC_ALGO */ 364 365 /* space for nested metrics */ 366 payload += nla_total_size((RTAX_MAX * nla_total_size(4))); 367 368 if (fi->fib_nhs) { | 272 ((nh->nh_flags ^ onh->nh_flags) & ~RTNH_COMPARE_MASK)) 273 return -1; 274 onh++; 275 } endfor_nexthops(fi); 276 return 0; 277} 278 279static inline unsigned int fib_devindex_hashfn(unsigned int val) --- 84 unchanged lines hidden (view full) --- 364 + nla_total_size(4) /* RTA_PRIORITY */ 365 + nla_total_size(4) /* RTA_PREFSRC */ 366 + nla_total_size(TCP_CA_NAME_MAX); /* RTAX_CC_ALGO */ 367 368 /* space for nested metrics */ 369 payload += nla_total_size((RTAX_MAX * nla_total_size(4))); 370 371 if (fi->fib_nhs) { |
372 size_t nh_encapsize = 0; |
|
369 /* Also handles the special case fib_nhs == 1 */ 370 371 /* each nexthop is packed in an attribute */ 372 size_t nhsize = nla_total_size(sizeof(struct rtnexthop)); 373 374 /* may contain flow and gateway attribute */ 375 nhsize += 2 * nla_total_size(4); 376 | 373 /* Also handles the special case fib_nhs == 1 */ 374 375 /* each nexthop is packed in an attribute */ 376 size_t nhsize = nla_total_size(sizeof(struct rtnexthop)); 377 378 /* may contain flow and gateway attribute */ 379 nhsize += 2 * nla_total_size(4); 380 |
381 /* grab encap info */ 382 for_nexthops(fi) { 383 if (nh->nh_lwtstate) { 384 /* RTA_ENCAP_TYPE */ 385 nh_encapsize += lwtunnel_get_encap_size( 386 nh->nh_lwtstate); 387 /* RTA_ENCAP */ 388 nh_encapsize += nla_total_size(2); 389 } 390 } endfor_nexthops(fi); 391 |
|
377 /* all nexthops are packed in a nested attribute */ | 392 /* all nexthops are packed in a nested attribute */ |
378 payload += nla_total_size(fi->fib_nhs * nhsize); | 393 payload += nla_total_size((fi->fib_nhs * nhsize) + 394 nh_encapsize); 395 |
379 } 380 381 return payload; 382} 383 384void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, 385 int dst_len, u32 tb_id, const struct nl_info *info, 386 unsigned int nlm_flags) --- 29 unchanged lines hidden (view full) --- 416{ 417 struct neighbour *n; 418 int state = NUD_NONE; 419 420 n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev); 421 if (n) { 422 state = n->nud_state; 423 neigh_release(n); | 396 } 397 398 return payload; 399} 400 401void rtmsg_fib(int event, __be32 key, struct fib_alias *fa, 402 int dst_len, u32 tb_id, const struct nl_info *info, 403 unsigned int nlm_flags) --- 29 unchanged lines hidden (view full) --- 433{ 434 struct neighbour *n; 435 int state = NUD_NONE; 436 437 n = neigh_lookup(&arp_tbl, &fi->fib_nh[0].nh_gw, fi->fib_dev); 438 if (n) { 439 state = n->nud_state; 440 neigh_release(n); |
441 } else { 442 return 0; |
|
424 } 425 if (state == NUD_REACHABLE) 426 return 0; 427 if ((state & NUD_VALID) && order != dflt) 428 return 0; 429 if ((state & NUD_VALID) || | 443 } 444 if (state == NUD_REACHABLE) 445 return 0; 446 if ((state & NUD_VALID) && order != dflt) 447 return 0; 448 if ((state & NUD_VALID) || |
430 (*last_idx < 0 && order > dflt)) { | 449 (*last_idx < 0 && order > dflt && state != NUD_INCOMPLETE)) { |
431 *last_resort = fi; 432 *last_idx = order; 433 } 434 return 1; 435} 436 437#ifdef CONFIG_IP_ROUTE_MULTIPATH 438 --- 8 unchanged lines hidden (view full) --- 447 448 /* leftover implies invalid nexthop configuration, discard it */ 449 return remaining > 0 ? 0 : nhs; 450} 451 452static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, 453 int remaining, struct fib_config *cfg) 454{ | 450 *last_resort = fi; 451 *last_idx = order; 452 } 453 return 1; 454} 455 456#ifdef CONFIG_IP_ROUTE_MULTIPATH 457 --- 8 unchanged lines hidden (view full) --- 466 467 /* leftover implies invalid nexthop configuration, discard it */ 468 return remaining > 0 ? 0 : nhs; 469} 470 471static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, 472 int remaining, struct fib_config *cfg) 473{ |
474 struct net *net = cfg->fc_nlinfo.nl_net; 475 int ret; 476 |
|
455 change_nexthops(fi) { 456 int attrlen; 457 458 if (!rtnh_ok(rtnh, remaining)) 459 return -EINVAL; 460 461 nexthop_nh->nh_flags = 462 (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; --- 7 unchanged lines hidden (view full) --- 470 nla = nla_find(attrs, attrlen, RTA_GATEWAY); 471 nexthop_nh->nh_gw = nla ? nla_get_in_addr(nla) : 0; 472#ifdef CONFIG_IP_ROUTE_CLASSID 473 nla = nla_find(attrs, attrlen, RTA_FLOW); 474 nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; 475 if (nexthop_nh->nh_tclassid) 476 fi->fib_net->ipv4.fib_num_tclassid_users++; 477#endif | 477 change_nexthops(fi) { 478 int attrlen; 479 480 if (!rtnh_ok(rtnh, remaining)) 481 return -EINVAL; 482 483 nexthop_nh->nh_flags = 484 (cfg->fc_flags & ~0xFF) | rtnh->rtnh_flags; --- 7 unchanged lines hidden (view full) --- 492 nla = nla_find(attrs, attrlen, RTA_GATEWAY); 493 nexthop_nh->nh_gw = nla ? nla_get_in_addr(nla) : 0; 494#ifdef CONFIG_IP_ROUTE_CLASSID 495 nla = nla_find(attrs, attrlen, RTA_FLOW); 496 nexthop_nh->nh_tclassid = nla ? nla_get_u32(nla) : 0; 497 if (nexthop_nh->nh_tclassid) 498 fi->fib_net->ipv4.fib_num_tclassid_users++; 499#endif |
500 nla = nla_find(attrs, attrlen, RTA_ENCAP); 501 if (nla) { 502 struct lwtunnel_state *lwtstate; 503 struct net_device *dev = NULL; 504 struct nlattr *nla_entype; 505 506 nla_entype = nla_find(attrs, attrlen, 507 RTA_ENCAP_TYPE); 508 if (!nla_entype) 509 goto err_inval; 510 if (cfg->fc_oif) 511 dev = __dev_get_by_index(net, cfg->fc_oif); 512 ret = lwtunnel_build_state(dev, nla_get_u16( 513 nla_entype), 514 nla, AF_INET, cfg, 515 &lwtstate); 516 if (ret) 517 goto errout; 518 nexthop_nh->nh_lwtstate = 519 lwtstate_get(lwtstate); 520 } |
|
478 } 479 480 rtnh = rtnh_next(rtnh, &remaining); 481 } endfor_nexthops(fi); 482 483 return 0; | 521 } 522 523 rtnh = rtnh_next(rtnh, &remaining); 524 } endfor_nexthops(fi); 525 526 return 0; |
527 528err_inval: 529 ret = -EINVAL; 530 531errout: 532 return ret; |
|
484} 485 486#endif 487 | 533} 534 535#endif 536 |
537static int fib_encap_match(struct net *net, u16 encap_type, 538 struct nlattr *encap, 539 int oif, const struct fib_nh *nh, 540 const struct fib_config *cfg) 541{ 542 struct lwtunnel_state *lwtstate; 543 struct net_device *dev = NULL; 544 int ret, result = 0; 545 546 if (encap_type == LWTUNNEL_ENCAP_NONE) 547 return 0; 548 549 if (oif) 550 dev = __dev_get_by_index(net, oif); 551 ret = lwtunnel_build_state(dev, encap_type, encap, 552 AF_INET, cfg, &lwtstate); 553 if (!ret) { 554 result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate); 555 lwtstate_free(lwtstate); 556 } 557 558 return result; 559} 560 |
|
488int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) 489{ | 561int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) 562{ |
563 struct net *net = cfg->fc_nlinfo.nl_net; |
|
490#ifdef CONFIG_IP_ROUTE_MULTIPATH 491 struct rtnexthop *rtnh; 492 int remaining; 493#endif 494 495 if (cfg->fc_priority && cfg->fc_priority != fi->fib_priority) 496 return 1; 497 498 if (cfg->fc_oif || cfg->fc_gw) { | 564#ifdef CONFIG_IP_ROUTE_MULTIPATH 565 struct rtnexthop *rtnh; 566 int remaining; 567#endif 568 569 if (cfg->fc_priority && cfg->fc_priority != fi->fib_priority) 570 return 1; 571 572 if (cfg->fc_oif || cfg->fc_gw) { |
573 if (cfg->fc_encap) { 574 if (fib_encap_match(net, cfg->fc_encap_type, 575 cfg->fc_encap, cfg->fc_oif, 576 fi->fib_nh, cfg)) 577 return 1; 578 } |
|
499 if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && 500 (!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->nh_gw)) 501 return 0; 502 return 1; 503 } 504 505#ifdef CONFIG_IP_ROUTE_MULTIPATH 506 if (!cfg->fc_mp) --- 73 unchanged lines hidden (view full) --- 580 * | 581 * |-> {link prefix} -> (gw, oif) [scope local] 582 * | 583 * |-> {local prefix} (terminal node) 584 */ 585static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, 586 struct fib_nh *nh) 587{ | 579 if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && 580 (!cfg->fc_gw || cfg->fc_gw == fi->fib_nh->nh_gw)) 581 return 0; 582 return 1; 583 } 584 585#ifdef CONFIG_IP_ROUTE_MULTIPATH 586 if (!cfg->fc_mp) --- 73 unchanged lines hidden (view full) --- 660 * | 661 * |-> {link prefix} -> (gw, oif) [scope local] 662 * | 663 * |-> {local prefix} (terminal node) 664 */ 665static int fib_check_nh(struct fib_config *cfg, struct fib_info *fi, 666 struct fib_nh *nh) 667{ |
588 int err; | 668 int err = 0; |
589 struct net *net; 590 struct net_device *dev; 591 592 net = cfg->fc_nlinfo.nl_net; 593 if (nh->nh_gw) { 594 struct fib_result res; 595 596 if (nh->nh_flags & RTNH_F_ONLINK) { | 669 struct net *net; 670 struct net_device *dev; 671 672 net = cfg->fc_nlinfo.nl_net; 673 if (nh->nh_gw) { 674 struct fib_result res; 675 676 if (nh->nh_flags & RTNH_F_ONLINK) { |
677 unsigned int addr_type; |
|
597 598 if (cfg->fc_scope >= RT_SCOPE_LINK) 599 return -EINVAL; | 678 679 if (cfg->fc_scope >= RT_SCOPE_LINK) 680 return -EINVAL; |
600 if (inet_addr_type(net, nh->nh_gw) != RTN_UNICAST) 601 return -EINVAL; | |
602 dev = __dev_get_by_index(net, nh->nh_oif); 603 if (!dev) 604 return -ENODEV; 605 if (!(dev->flags & IFF_UP)) 606 return -ENETDOWN; | 681 dev = __dev_get_by_index(net, nh->nh_oif); 682 if (!dev) 683 return -ENODEV; 684 if (!(dev->flags & IFF_UP)) 685 return -ENETDOWN; |
686 addr_type = inet_addr_type_dev_table(net, dev, nh->nh_gw); 687 if (addr_type != RTN_UNICAST) 688 return -EINVAL; |
|
607 if (!netif_carrier_ok(dev)) 608 nh->nh_flags |= RTNH_F_LINKDOWN; 609 nh->nh_dev = dev; 610 dev_hold(dev); 611 nh->nh_scope = RT_SCOPE_LINK; 612 return 0; 613 } 614 rcu_read_lock(); 615 { | 689 if (!netif_carrier_ok(dev)) 690 nh->nh_flags |= RTNH_F_LINKDOWN; 691 nh->nh_dev = dev; 692 dev_hold(dev); 693 nh->nh_scope = RT_SCOPE_LINK; 694 return 0; 695 } 696 rcu_read_lock(); 697 { |
698 struct fib_table *tbl = NULL; |
|
616 struct flowi4 fl4 = { 617 .daddr = nh->nh_gw, 618 .flowi4_scope = cfg->fc_scope + 1, 619 .flowi4_oif = nh->nh_oif, 620 .flowi4_iif = LOOPBACK_IFINDEX, 621 }; 622 623 /* It is not necessary, but requires a bit of thinking */ 624 if (fl4.flowi4_scope < RT_SCOPE_LINK) 625 fl4.flowi4_scope = RT_SCOPE_LINK; | 699 struct flowi4 fl4 = { 700 .daddr = nh->nh_gw, 701 .flowi4_scope = cfg->fc_scope + 1, 702 .flowi4_oif = nh->nh_oif, 703 .flowi4_iif = LOOPBACK_IFINDEX, 704 }; 705 706 /* It is not necessary, but requires a bit of thinking */ 707 if (fl4.flowi4_scope < RT_SCOPE_LINK) 708 fl4.flowi4_scope = RT_SCOPE_LINK; |
626 err = fib_lookup(net, &fl4, &res, 627 FIB_LOOKUP_IGNORE_LINKSTATE); | 709 710 if (cfg->fc_table) 711 tbl = fib_get_table(net, cfg->fc_table); 712 713 if (tbl) 714 err = fib_table_lookup(tbl, &fl4, &res, 715 FIB_LOOKUP_IGNORE_LINKSTATE | 716 FIB_LOOKUP_NOREF); 717 718 /* on error or if no table given do full lookup. This 719 * is needed for example when nexthops are in the local 720 * table rather than the given table 721 */ 722 if (!tbl || err) { 723 err = fib_lookup(net, &fl4, &res, 724 FIB_LOOKUP_IGNORE_LINKSTATE); 725 } 726 |
628 if (err) { 629 rcu_read_unlock(); 630 return err; 631 } 632 } 633 err = -EINVAL; 634 if (res.type != RTN_UNICAST && res.type != RTN_LOCAL) 635 goto out; --- 119 unchanged lines hidden (view full) --- 755 nh->nh_saddr = inet_select_addr(nh->nh_dev, 756 nh->nh_gw, 757 nh->nh_parent->fib_scope); 758 nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid); 759 760 return nh->nh_saddr; 761} 762 | 727 if (err) { 728 rcu_read_unlock(); 729 return err; 730 } 731 } 732 err = -EINVAL; 733 if (res.type != RTN_UNICAST && res.type != RTN_LOCAL) 734 goto out; --- 119 unchanged lines hidden (view full) --- 854 nh->nh_saddr = inet_select_addr(nh->nh_dev, 855 nh->nh_gw, 856 nh->nh_parent->fib_scope); 857 nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid); 858 859 return nh->nh_saddr; 860} 861 |
862static bool fib_valid_prefsrc(struct fib_config *cfg, __be32 fib_prefsrc) 863{ 864 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || 865 fib_prefsrc != cfg->fc_dst) { 866 int tb_id = cfg->fc_table; 867 868 if (tb_id == RT_TABLE_MAIN) 869 tb_id = RT_TABLE_LOCAL; 870 871 if (inet_addr_type_table(cfg->fc_nlinfo.nl_net, 872 fib_prefsrc, tb_id) != RTN_LOCAL) { 873 return false; 874 } 875 } 876 return true; 877} 878 |
|
763struct fib_info *fib_create_info(struct fib_config *cfg) 764{ 765 int err; 766 struct fib_info *fi = NULL; 767 struct fib_info *ofi; 768 int nhs = 1; 769 struct net *net = cfg->fc_nlinfo.nl_net; 770 --- 106 unchanged lines hidden (view full) --- 877 goto err_inval; 878#endif 879#else 880 goto err_inval; 881#endif 882 } else { 883 struct fib_nh *nh = fi->fib_nh; 884 | 879struct fib_info *fib_create_info(struct fib_config *cfg) 880{ 881 int err; 882 struct fib_info *fi = NULL; 883 struct fib_info *ofi; 884 int nhs = 1; 885 struct net *net = cfg->fc_nlinfo.nl_net; 886 --- 106 unchanged lines hidden (view full) --- 993 goto err_inval; 994#endif 995#else 996 goto err_inval; 997#endif 998 } else { 999 struct fib_nh *nh = fi->fib_nh; 1000 |
1001 if (cfg->fc_encap) { 1002 struct lwtunnel_state *lwtstate; 1003 struct net_device *dev = NULL; 1004 1005 if (cfg->fc_encap_type == LWTUNNEL_ENCAP_NONE) 1006 goto err_inval; 1007 if (cfg->fc_oif) 1008 dev = __dev_get_by_index(net, cfg->fc_oif); 1009 err = lwtunnel_build_state(dev, cfg->fc_encap_type, 1010 cfg->fc_encap, AF_INET, cfg, 1011 &lwtstate); 1012 if (err) 1013 goto failure; 1014 1015 nh->nh_lwtstate = lwtstate_get(lwtstate); 1016 } |
|
885 nh->nh_oif = cfg->fc_oif; 886 nh->nh_gw = cfg->fc_gw; 887 nh->nh_flags = cfg->fc_flags; 888#ifdef CONFIG_IP_ROUTE_CLASSID 889 nh->nh_tclassid = cfg->fc_flow; 890 if (nh->nh_tclassid) 891 fi->fib_net->ipv4.fib_num_tclassid_users++; 892#endif --- 42 unchanged lines hidden (view full) --- 935 goto failure; 936 if (nexthop_nh->nh_flags & RTNH_F_LINKDOWN) 937 linkdown++; 938 } endfor_nexthops(fi) 939 if (linkdown == fi->fib_nhs) 940 fi->fib_flags |= RTNH_F_LINKDOWN; 941 } 942 | 1017 nh->nh_oif = cfg->fc_oif; 1018 nh->nh_gw = cfg->fc_gw; 1019 nh->nh_flags = cfg->fc_flags; 1020#ifdef CONFIG_IP_ROUTE_CLASSID 1021 nh->nh_tclassid = cfg->fc_flow; 1022 if (nh->nh_tclassid) 1023 fi->fib_net->ipv4.fib_num_tclassid_users++; 1024#endif --- 42 unchanged lines hidden (view full) --- 1067 goto failure; 1068 if (nexthop_nh->nh_flags & RTNH_F_LINKDOWN) 1069 linkdown++; 1070 } endfor_nexthops(fi) 1071 if (linkdown == fi->fib_nhs) 1072 fi->fib_flags |= RTNH_F_LINKDOWN; 1073 } 1074 |
943 if (fi->fib_prefsrc) { 944 if (cfg->fc_type != RTN_LOCAL || !cfg->fc_dst || 945 fi->fib_prefsrc != cfg->fc_dst) 946 if (inet_addr_type(net, fi->fib_prefsrc) != RTN_LOCAL) 947 goto err_inval; 948 } | 1075 if (fi->fib_prefsrc && !fib_valid_prefsrc(cfg, fi->fib_prefsrc)) 1076 goto err_inval; |
949 950 change_nexthops(fi) { 951 fib_info_update_nh_saddr(net, nexthop_nh); 952 } endfor_nexthops(fi) 953 954link_it: 955 ofi = fib_find_info(fi); 956 if (ofi) { --- 93 unchanged lines hidden (view full) --- 1050 IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev)) 1051 rtm->rtm_flags |= RTNH_F_DEAD; 1052 } 1053#ifdef CONFIG_IP_ROUTE_CLASSID 1054 if (fi->fib_nh[0].nh_tclassid && 1055 nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid)) 1056 goto nla_put_failure; 1057#endif | 1077 1078 change_nexthops(fi) { 1079 fib_info_update_nh_saddr(net, nexthop_nh); 1080 } endfor_nexthops(fi) 1081 1082link_it: 1083 ofi = fib_find_info(fi); 1084 if (ofi) { --- 93 unchanged lines hidden (view full) --- 1178 IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN(in_dev)) 1179 rtm->rtm_flags |= RTNH_F_DEAD; 1180 } 1181#ifdef CONFIG_IP_ROUTE_CLASSID 1182 if (fi->fib_nh[0].nh_tclassid && 1183 nla_put_u32(skb, RTA_FLOW, fi->fib_nh[0].nh_tclassid)) 1184 goto nla_put_failure; 1185#endif |
1186 if (fi->fib_nh->nh_lwtstate) 1187 lwtunnel_fill_encap(skb, fi->fib_nh->nh_lwtstate); |
|
1058 } 1059#ifdef CONFIG_IP_ROUTE_MULTIPATH 1060 if (fi->fib_nhs > 1) { 1061 struct rtnexthop *rtnh; 1062 struct nlattr *mp; 1063 1064 mp = nla_nest_start(skb, RTA_MULTIPATH); 1065 if (!mp) --- 19 unchanged lines hidden (view full) --- 1085 if (nh->nh_gw && 1086 nla_put_in_addr(skb, RTA_GATEWAY, nh->nh_gw)) 1087 goto nla_put_failure; 1088#ifdef CONFIG_IP_ROUTE_CLASSID 1089 if (nh->nh_tclassid && 1090 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) 1091 goto nla_put_failure; 1092#endif | 1188 } 1189#ifdef CONFIG_IP_ROUTE_MULTIPATH 1190 if (fi->fib_nhs > 1) { 1191 struct rtnexthop *rtnh; 1192 struct nlattr *mp; 1193 1194 mp = nla_nest_start(skb, RTA_MULTIPATH); 1195 if (!mp) --- 19 unchanged lines hidden (view full) --- 1215 if (nh->nh_gw && 1216 nla_put_in_addr(skb, RTA_GATEWAY, nh->nh_gw)) 1217 goto nla_put_failure; 1218#ifdef CONFIG_IP_ROUTE_CLASSID 1219 if (nh->nh_tclassid && 1220 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) 1221 goto nla_put_failure; 1222#endif |
1223 if (nh->nh_lwtstate) 1224 lwtunnel_fill_encap(skb, nh->nh_lwtstate); |
|
1093 /* length of rtnetlink header + attributes */ 1094 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh; 1095 } endfor_nexthops(fi); 1096 1097 nla_nest_end(skb, mp); 1098 } 1099#endif 1100 nlmsg_end(skb, nlh); --- 300 unchanged lines hidden --- | 1225 /* length of rtnetlink header + attributes */ 1226 rtnh->rtnh_len = nlmsg_get_pos(skb) - (void *) rtnh; 1227 } endfor_nexthops(fi); 1228 1229 nla_nest_end(skb, mp); 1230 } 1231#endif 1232 nlmsg_end(skb, nlh); --- 300 unchanged lines hidden --- |