Commits

Stas Nichiporovich authored and Donald Sharp committed aef4650851c
zebra: fix crash caused by using route-map with "set src"

Signed-off-by: Stas Nichiporovich <stas@iptel.by> Tested-by: NetDEF CI System <cisystem@netdef.org>
No tags

zebra/zebra_routemap.c

Modified
417 417
418 418 /* `match ip next-hop IP_ACCESS_LIST' */
419 419
420 420 /* Match function return 1 if match is success else return zero. */
421 421 static route_map_result_t
422 422 route_match_ip_next_hop (void *rule, struct prefix *prefix,
423 423 route_map_object_t type, void *object)
424 424 {
425 425 struct access_list *alist;
426 426 struct nexthop *nexthop;
427 + struct nexthop_vrfid *nh_vrf;
427 428 struct prefix_ipv4 p;
428 429
429 430 if (type == RMAP_ZEBRA)
430 431 {
431 - nexthop = object;
432 + nh_vrf = object;
433 + nexthop = nh_vrf->nexthop;
432 434 switch (nexthop->type) {
433 435 case NEXTHOP_TYPE_IFINDEX:
434 436 case NEXTHOP_TYPE_IFNAME:
435 437 /* Interface routes can't match ip next-hop */
436 438 return RMAP_NOMATCH;
437 439 case NEXTHOP_TYPE_IPV4_IFINDEX:
438 440 case NEXTHOP_TYPE_IPV4_IFNAME:
439 441 case NEXTHOP_TYPE_IPV4:
440 442 p.family = AF_INET;
441 443 p.prefix = nexthop->gate.ipv4;
479 481 };
480 482
481 483 /* `match ip next-hop prefix-list PREFIX_LIST' */
482 484
483 485 static route_map_result_t
484 486 route_match_ip_next_hop_prefix_list (void *rule, struct prefix *prefix,
485 487 route_map_object_t type, void *object)
486 488 {
487 489 struct prefix_list *plist;
488 490 struct nexthop *nexthop;
491 + struct nexthop_vrfid *nh_vrf;
489 492 struct prefix_ipv4 p;
490 493
491 494 if (type == RMAP_ZEBRA)
492 495 {
493 - nexthop = object;
496 + nh_vrf = object;
497 + nexthop = nh_vrf->nexthop;
494 498 switch (nexthop->type) {
495 499 case NEXTHOP_TYPE_IFINDEX:
496 500 case NEXTHOP_TYPE_IFNAME:
497 501 /* Interface routes can't match ip next-hop */
498 502 return RMAP_NOMATCH;
499 503 case NEXTHOP_TYPE_IPV4_IFINDEX:
500 504 case NEXTHOP_TYPE_IPV4_IFNAME:
501 505 case NEXTHOP_TYPE_IPV4:
502 506 p.family = AF_INET;
503 507 p.prefix = nexthop->gate.ipv4;
625 629
626 630 /* `set src A.B.C.D' */
627 631
628 632 /* Set src. */
629 633 static route_map_result_t
630 634 route_set_src (void *rule, struct prefix *prefix,
631 635 route_map_object_t type, void *object)
632 636 {
633 637 if (type == RMAP_ZEBRA)
634 638 {
635 - struct nexthop *nexthop;
639 + struct nexthop_vrfid *nh_vrf;
636 640
637 - nexthop = object;
638 - nexthop->src = *(union g_addr *)rule;
641 + nh_vrf = object;
642 + nh_vrf->nexthop->src = *(union g_addr *)rule;
639 643 }
640 644 return RMAP_OKAY;
641 645 }
642 646
643 647 /* set src compilation. */
644 648 static void *
645 649 route_set_src_compile (const char *arg)
646 650 {
647 651 union g_addr src, *psrc;
648 652

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut