• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/zebra/bgpd/

Lines Matching refs:attr

282 attrhash_key_make (struct attr *attr)
286 key += attr->origin;
287 key += attr->nexthop.s_addr;
288 key += attr->med;
289 key += attr->local_pref;
290 key += attr->aggregator_as;
291 key += attr->aggregator_addr.s_addr;
292 key += attr->weight;
294 key += attr->mp_nexthop_global_in.s_addr;
295 if (attr->aspath)
296 key += aspath_key_make (attr->aspath);
297 if (attr->community)
298 key += community_hash_make (attr->community);
299 if (attr->ecommunity)
300 key += ecommunity_hash_make (attr->ecommunity);
301 if (attr->cluster)
302 key += cluster_hash_key_make (attr->cluster);
303 if (attr->transit)
304 key += transit_hash_key_make (attr->transit);
310 key += attr->mp_nexthop_len;
312 key += attr->mp_nexthop_global.s6_addr[i];
314 key += attr->mp_nexthop_local.s6_addr[i];
322 attrhash_cmp (struct attr *attr1, struct attr *attr2)
357 struct attr *attr = backet->data;
359 vty_out (vty, "attr[%ld] nexthop %s%s", attr->refcnt,
360 inet_ntoa (attr->nexthop), VTY_NEWLINE);
373 bgp_attr_hash_alloc (struct attr *val)
375 struct attr *attr;
377 attr = XMALLOC (MTYPE_ATTR, sizeof (struct attr));
378 *attr = *val;
379 attr->refcnt = 0;
380 return attr;
384 struct attr *
385 bgp_attr_intern (struct attr *attr)
387 struct attr *find;
390 if (attr->aspath)
392 if (! attr->aspath->refcnt)
393 attr->aspath = aspath_intern (attr->aspath);
395 attr->aspath->refcnt++;
397 if (attr->community)
399 if (! attr->community->refcnt)
400 attr->community = community_intern (attr->community);
402 attr->community->refcnt++;
404 if (attr->ecommunity)
406 if (! attr->ecommunity->refcnt)
407 attr->ecommunity = ecommunity_intern (attr->ecommunity);
409 attr->ecommunity->refcnt++;
411 if (attr->cluster)
413 if (! attr->cluster->refcnt)
414 attr->cluster = cluster_intern (attr->cluster);
416 attr->cluster->refcnt++;
418 if (attr->transit)
420 if (! attr->transit->refcnt)
421 attr->transit = transit_intern (attr->transit);
423 attr->transit->refcnt++;
426 find = (struct attr *) hash_get (attrhash, attr, bgp_attr_hash_alloc);
433 struct attr *
434 bgp_attr_default_set (struct attr *attr, u_char origin)
436 memset (attr, 0, sizeof (struct attr));
438 attr->origin = origin;
439 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
440 attr->aspath = aspath_empty ();
441 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
442 attr->weight = 32768;
443 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
445 attr->mp_nexthop_len = 16;
447 return attr;
451 struct attr *
454 struct attr attr;
455 struct attr *new;
457 memset (&attr, 0, sizeof (struct attr));
459 attr.origin = origin;
460 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
461 attr.aspath = aspath_empty ();
462 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
463 attr.weight = 32768;
464 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
466 attr.mp_nexthop_len = 16;
469 new = bgp_attr_intern (&attr);
474 struct attr *
479 struct attr attr;
480 struct attr *new;
482 memset (&attr, 0, sizeof (struct attr));
485 attr.origin = origin;
486 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
490 attr.aspath = aspath_intern (aspath);
492 attr.aspath = aspath_empty ();
493 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
496 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
500 attr.community = community;
501 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
504 attr.weight = 32768;
506 attr.mp_nexthop_len = 16;
509 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
510 attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
512 attr.aggregator_as = bgp->confed_id;
514 attr.aggregator_as = bgp->as;
515 attr.aggregator_addr = bgp->router_id;
517 new = bgp_attr_intern (&attr);
524 bgp_attr_unintern (struct attr *attr)
526 struct attr *ret;
534 attr->refcnt--;
535 aspath = attr->aspath;
536 community = attr->community;
537 ecommunity = attr->ecommunity;
538 cluster = attr->cluster;
539 transit = attr->transit;
542 if (attr->refcnt == 0)
544 ret = hash_release (attrhash, attr);
546 XFREE (MTYPE_ATTR, attr);
563 bgp_attr_flush (struct attr *attr)
565 if (attr->aspath && ! attr->aspath->refcnt)
566 aspath_free (attr->aspath);
567 if (attr->community && ! attr->community->refcnt)
568 community_free (attr->community);
569 if (attr->ecommunity && ! attr->ecommunity->refcnt)
570 ecommunity_free (attr->ecommunity);
571 if (attr->cluster && ! attr->cluster->refcnt)
572 cluster_free (attr->cluster);
573 if (attr->transit && ! attr->transit->refcnt)
574 transit_free (attr->transit);
580 struct attr *attr, u_char flag, u_char *startp)
619 attr->origin = stream_getc (BGP_INPUT (peer));
624 if ((attr->origin != BGP_ORIGIN_IGP)
625 && (attr->origin != BGP_ORIGIN_EGP)
626 && (attr->origin != BGP_ORIGIN_INCOMPLETE))
629 attr->origin);
639 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGIN);
648 struct attr *attr, u_char flag, u_char *startp)
670 attr->aspath = aspath_parse (stream_pnt (peer->ibuf), length);
671 if (! attr->aspath)
686 && ! aspath_firstas_check (attr->aspath, peer->as))
701 aspath = aspath_dup (attr->aspath);
703 aspath_unintern (attr->aspath);
704 attr->aspath = aspath_intern (aspath);
711 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AS_PATH);
719 struct attr *attr, u_char flag, u_char *startp)
751 attr->nexthop.s_addr = stream_get_ipv4 (peer->ibuf);
752 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP);
760 struct attr *attr, u_char flag, u_char *startp)
779 attr->med = stream_getl (peer->ibuf);
781 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC);
789 struct attr *attr, u_char flag)
801 attr->local_pref = stream_getl (peer->ibuf);
803 attr->local_pref = 0;
806 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF);
814 struct attr *attr, u_char flag)
827 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE);
835 struct attr *attr, u_char flag)
846 attr->aggregator_as = stream_getw (peer->ibuf);
847 attr->aggregator_addr.s_addr = stream_get_ipv4 (peer->ibuf);
850 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR);
858 struct attr *attr, u_char flag)
861 attr->community = NULL;
864 attr->community = community_parse (stream_pnt (peer->ibuf), length);
868 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES);
876 struct attr *attr, u_char flag)
888 attr->originator_id.s_addr = stream_get_ipv4 (peer->ibuf);
890 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_ORIGINATOR_ID);
898 struct attr *attr, u_char flag)
911 attr->cluster = cluster_parse (stream_pnt (peer->ibuf), length);
915 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_CLUSTER_LIST);
922 bgp_mp_reach_parse (struct peer *peer, bgp_size_t length, struct attr *attr,
943 attr->mp_nexthop_len = stream_getc (s);
946 switch (attr->mp_nexthop_len)
949 stream_get (&attr->mp_nexthop_global_in, s, 4);
958 stream_get (&attr->mp_nexthop_global_in, s, 4);
963 stream_get (&attr->mp_nexthop_global, s, 16);
966 stream_get (&attr->mp_nexthop_global, s, 16);
967 stream_get (&attr->mp_nexthop_local, s, 16);
968 if (! IN6_IS_ADDR_LINKLOCAL (&attr->mp_nexthop_local))
975 inet_ntop (AF_INET6, &attr->mp_nexthop_global,
977 inet_ntop (AF_INET6, &attr->mp_nexthop_local,
980 attr->mp_nexthop_len = 16;
986 attr->mp_nexthop_len);
1066 struct attr *attr, u_char flag)
1069 attr->ecommunity = NULL;
1072 attr->ecommunity = ecommunity_parse (stream_pnt (peer->ibuf), length);
1075 attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES);
1082 bgp_attr_unknown (struct peer *peer, struct attr *attr, u_char flag,
1123 /* Store transitive attribute to the end of attr->transit. */
1124 if (! attr->transit)
1126 attr->transit = XMALLOC (MTYPE_TRANSIT, sizeof (struct transit));
1127 memset (attr->transit, 0, sizeof (struct transit));
1130 transit = attr->transit;
1147 bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size,
1229 ret = bgp_attr_origin (peer, length, attr, flag, startp);
1232 ret = bgp_attr_aspath (peer, length, attr, flag, startp);
1235 ret = bgp_attr_nexthop (peer, length, attr, flag, startp);
1238 ret = bgp_attr_med (peer, length, attr, flag, startp);
1241 ret = bgp_attr_local_pref (peer, length, attr, flag);
1244 ret = bgp_attr_atomic (peer, length, attr, flag);
1247 ret = bgp_attr_aggregator (peer, length, attr, flag);
1250 ret = bgp_attr_community (peer, length, attr, flag);
1253 ret = bgp_attr_originator_id (peer, length, attr, flag);
1256 ret = bgp_attr_cluster_list (peer, length, attr, flag);
1259 ret = bgp_mp_reach_parse (peer, length, attr, mp_update);
1265 ret = bgp_attr_ext_communities (peer, length, attr, flag);
1268 ret = bgp_attr_unknown (peer, attr, flag, type, length, startp);
1300 if (attr->transit)
1301 attr->transit = transit_intern (attr->transit);
1308 bgp_attr_check (struct peer *peer, struct attr *attr)
1312 if (! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_ORIGIN)))
1315 if (! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_AS_PATH)))
1318 if (! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP)))
1322 && ! CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF)))
1345 struct stream *s, struct attr *attr, struct prefix *p,
1362 stream_putc (s, attr->origin);
1369 || attr->aspath->length == 0)
1373 aspath = aspath_dup (attr->aspath);
1392 aspath = aspath_dup (attr->aspath);
1396 aspath = attr->aspath;
1413 if (aspath != attr->aspath)
1417 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP) && afi == AFI_IP)
1424 if (attr->nexthop.s_addr == 0)
1427 stream_put_ipv4 (s, attr->nexthop.s_addr);
1430 stream_put_ipv4 (s, attr->nexthop.s_addr);
1434 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
1439 stream_putl (s, attr->med);
1449 stream_putl (s, attr->local_pref);
1453 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))
1461 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))
1466 stream_putw (s, attr->aggregator_as);
1467 stream_put_ipv4 (s, attr->aggregator_addr.s_addr);
1472 && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES)))
1474 if (attr->community->size * 4 > 255)
1478 stream_putw (s, attr->community->size * 4);
1484 stream_putc (s, attr->community->size * 4);
1486 stream_put (s, attr->community->val, attr->community->size * 4);
1499 if (attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID))
1500 stream_put_in_addr (s, &attr->originator_id);
1506 stream_put_in_addr (s, &attr->originator_id);
1513 if (attr->cluster)
1515 stream_putc (s, attr->cluster->length + 4);
1521 stream_put (s, attr->cluster->list, attr->cluster->length);
1548 stream_putc (s, attr->mp_nexthop_len);
1550 if (attr->mp_nexthop_len == 16)
1551 stream_put (s, &attr->mp_nexthop_global, 16);
1552 else if (attr->mp_nexthop_len == 32)
1554 stream_put (s, &attr->mp_nexthop_global, 16);
1555 stream_put (s, &attr->mp_nexthop_local, 16);
1593 stream_put_ipv4 (s, attr->nexthop.s_addr);
1631 stream_put (s, &attr->mp_nexthop_global_in, 4);
1659 && (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_EXT_COMMUNITIES)))
1661 if (attr->ecommunity->size * 8 > 255)
1665 stream_putw (s, attr->ecommunity->size * 8);
1671 stream_putc (s, attr->ecommunity->size * 8);
1673 stream_put (s, attr->ecommunity->val, attr->ecommunity->size * 8);
1677 if (attr->transit)
1678 stream_put (s, attr->transit->val, attr->transit->length);
1746 bgp_dump_routes_attr (struct stream *s, struct attr *attr)
1762 stream_putc (s, attr->origin);
1764 aspath = attr->aspath;
1784 stream_put_ipv4 (s, attr->nexthop.s_addr);
1787 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
1792 stream_putl (s, attr->med);
1796 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))
1801 stream_putl (s, attr->local_pref);
1805 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE))
1813 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR))
1818 stream_putw (s, attr->aggregator_as);
1819 stream_put_ipv4 (s, attr->aggregator_addr.s_addr);
1823 if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES))
1825 if (attr->community->size * 4 > 255)
1829 stream_putw (s, attr->community->size * 4);
1835 stream_putc (s, attr->community->size * 4);
1837 stream_put (s, attr->community->val, attr->community->size * 4);