Skip to content

Commit

Permalink
- do not send UPDATE back to originator to prevent IBGP reflection loops
Browse files Browse the repository at this point in the history
- use separate line to print originator ID in dump.c
  • Loading branch information
jinmei committed Mar 3, 2000
1 parent 1a24a6e commit 99c96e1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 33 deletions.
4 changes: 3 additions & 1 deletion kame/kame/bgpd/aspath.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,9 @@ msg2clstrlist(bnp, i, len)
if (IamRR &&
clusterId != 0 && /* global */
clusterId == cll->cll_id) { /* loop detection */
syslog(LOG_ERR, "<msg2clstrlist>: Cluster-list loop detected: %s", buf);
syslog(LOG_NOTICE,
"<%s>: Cluster-list loop detected: %s from %s",
__FUNCTION__, buf, bgp_peerstr(bnp));
free_clstrlist(cll);
return NULL;
}
Expand Down
48 changes: 20 additions & 28 deletions kame/kame/bgpd/bgp_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ bgp_send_update(bnp, rte, headrte)
if (bnp->rp_state != BGPSTATE_ESTABLISHED)
fatalx("<bgp_send_update>: internal error: invalid state");


if (rte == NULL) { /* argument */
IFLOG(LOG_BGPOUTPUT)
syslog(LOG_DEBUG, "<%s>: Nothing to be sent.", __FUNCTION__);
Expand Down Expand Up @@ -369,16 +368,12 @@ bgp_send_update(bnp, rte, headrte)
i += 2;
/* IPv6 (BGP4+) doesn't send this. */


/* Total Path Attribute Length (2 octets) (0...65535) */
i += 2;

topa_p = i;


rtp = &rte->rt_proto; /* identical to each RTE */


/*
* Path Attributes
*/
Expand Down Expand Up @@ -413,7 +408,6 @@ bgp_send_update(bnp, rte, headrte)
/*NOTREACHED*/
}


switch (origin) {
case PATH_ORG_IGP: case PATH_ORG_EGP: case PATH_ORG_XX:
outpkt[i] = origin;
Expand All @@ -425,9 +419,7 @@ bgp_send_update(bnp, rte, headrte)
break;
}


i += PA4_LEN_ORIGIN;


/** AS_PATH (Type Code 2) **/ /* well-known mandatory */
outpkt[i++] |= PA_FLAG_TRANS; /* well-known mandatory */
Expand Down Expand Up @@ -472,18 +464,14 @@ bgp_send_update(bnp, rte, headrte)
BGP_LOG_ATTR;
outpkt[i++] = sizeof(struct in_addr); /* L (IPv4 specific) */
/* V */

/* added by jinmei to interoperate with CISCO */
memcpy(&outpkt[i], (void *)&bgpIdentifier, PA_LEN_NEXTHOP);

i += PA_LEN_NEXTHOP; /* IPv4 address makes "no sense" */



/** MULTI_EXIT_DISC (Type Code 4) optional non-transitive **/
/* which received from a neighboring AS [BGP4+ 5.1.4] */
/* MUST NOT be propagated to other neighboring ASs */

if ((bnp->rp_mode & BGPO_IGP) &&
rte->rt_aspath &&
rte->rt_aspath->asp_med != 0) /* net-order */
Expand Down Expand Up @@ -525,16 +513,14 @@ bgp_send_update(bnp, rte, headrte)
/* no data */
}


/** ORIGINATOR_ID (Type Code 9) optional non-transitive */
/*
ORIGINATOR_ID is a new optional, non-transitive BGP attribute of Type
code 9. This attribute is 4 bytes long and it will be created by a
RR. This attribute will carry the ROUTER_ID of the originator of the
route in the local AS. A BGP speaker should not create an
ORIGINATOR_ID attribute if one already exists. A route reflector
must never send routing information back to the router specified in
ORIGINATOR_ID. */
* ORIGINATOR_ID is a new optional, non-transitive BGP attribute of Type
* code 9. This attribute is 4 bytes long and it will be created by a
* RR. This attribute will carry the ROUTER_ID of the originator of the
* route in the local AS. A BGP speaker should not create an
* ORIGINATOR_ID attribute if one already exists.
*/
if (IamRR &&
(bnp->rp_mode & BGPO_IGP)) {

Expand All @@ -545,6 +531,20 @@ bgp_send_update(bnp, rte, headrte)
netorigid = (rte->rt_aspath && (rte->rt_aspath->asp_origid != 0)) ?
rte->rt_aspath->asp_origid : rtp->rtp_bgp->rp_id;

/*
* A route reflector must never send routing information back to the
* router specified in ORIGINATOR_ID.
*/
if (netorigid == bnp->rp_id) {
IFLOG(LOG_BGPOUTPUT)
syslog(LOG_DEBUG,
"<%s>: UPDATE to %s is prevented since it's going to be "
"looped (Origin ID: %s)",
__FUNCTION__, bgp_peerstr(bnp),
inet_ntoa(*(struct in_addr *)&netorigid));
return(NULL);
}

outpkt[i++] |= PA_FLAG_OPT;
outpkt[i++] = PA4_TYPE_ORIGINATOR; /* T */
BGP_LOG_ATTR;
Expand All @@ -554,7 +554,6 @@ bgp_send_update(bnp, rte, headrte)
inet_ntoa(*(struct in_addr *)&netorigid));
memcpy(&outpkt[i], &netorigid, PA4_LEN_ORIGINATOR);
i += PA4_LEN_ORIGINATOR;

}
}

Expand Down Expand Up @@ -601,8 +600,6 @@ bgp_send_update(bnp, rte, headrte)
free_clstrlist(cll);
}



/** **/
/** MP_REACH_NLRI (Type Code 14) (optional non-transitive) **/
/** **/
Expand Down Expand Up @@ -894,8 +891,6 @@ bgp_send_update(bnp, rte, headrte)
return rt; /* the last RTE. */
}



/*
*
* bgp_send_withdrawn()
Expand Down Expand Up @@ -1043,9 +1038,6 @@ bgp_send_withdrawn(bnp, rte, headrte)
/********** End of MP_UnReach_NLRI **********/
/********** **********/




/* Total Path Attribute Length (2 octets) */
nettpalen = htons(i - topa_p);
memcpy(&outpkt[topa_p - 2], &nettpalen, 2);
Expand Down
13 changes: 9 additions & 4 deletions kame/kame/bgpd/dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,14 +297,20 @@ dump_bgp_rtentry(FILE *fp, struct rt_entry *rte, char *indent)
}

fprintf(fp, "%s ", indent); /* more indent */
fprintf(fp, "MED: %d localpref: %d origin: ID=%s,code=%s\n",
fprintf(fp, "MED: %d localpref: %d origin: %s\n",
(int)ntohl(ap->asp_med), (int)ntohl(ap->asp_localpref),
inet_ntop(AF_INET, &ap->asp_origid,
inetaddrstr, INET_ADDRSTRLEN),
origin_str[ap->asp_origin]);

fprintf(fp, "%s ", indent); /* more indent */
fprintf(fp, "ASPATH: %s\n", aspath2str(ap));

/* Route Reflection Origin ID and Cluster list*/
if (ap->asp_origid) {
fprintf(fp, "%s ", indent); /* more indent */
fprintf(fp, "Originator ID: %s\n",
inet_ntop(AF_INET, &ap->asp_origid,
inetaddrstr, INET_ADDRSTRLEN));
}
if (ap->asp_clstr) {
fprintf(fp, "%s ", indent); /* more indent */
fprintf(fp, "Cluster list: %s\n",
Expand All @@ -325,7 +331,6 @@ dump_bgp_rtentry(FILE *fp, struct rt_entry *rte, char *indent)
fprintf(fp, "...");
fputc('\n', fp);
}

}

static void
Expand Down

0 comments on commit 99c96e1

Please sign in to comment.