|
Line 791
Link Here
|
|
|
791 |
peer->password = NULL; |
|
Line 1205
Link Here
|
|
|
1206 |
|
| 1207 |
#ifdef HAVE_TCP_MD5SIG |
| 1208 |
/* Password configuration */ |
| 1209 |
if (peer->password) |
| 1210 |
{ |
| 1211 |
free (peer->password); |
| 1212 |
peer->password = NULL; |
| 1213 |
|
| 1214 |
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP) |
| 1215 |
&& sockunion_family (&peer->su) == AF_INET) |
| 1216 |
bgp_md5_set (bm->sock, &peer->su.sin, NULL); |
| 1217 |
} |
| 1218 |
#endif /* HAVE_TCP_MD5SIG */ |
| 1219 |
|
|
Line 1420
Link Here
|
|
|
1435 |
#ifdef HAVE_TCP_MD5SIG |
| 1436 |
/* password apply */ |
| 1437 |
if (CHECK_FLAG (conf->flags, PEER_FLAG_PASSWORD)) |
| 1438 |
{ |
| 1439 |
if (peer->password) |
| 1440 |
free (peer->password); |
| 1441 |
peer->password = strdup (conf->password); |
| 1442 |
|
| 1443 |
if (sockunion_family (&peer->su) == AF_INET) |
| 1444 |
bgp_md5_set (bm->sock, &peer->su.sin, peer->password); |
| 1445 |
} |
| 1446 |
else if (peer->password) |
| 1447 |
{ |
| 1448 |
free (peer->password); |
| 1449 |
peer->password = NULL; |
| 1450 |
|
| 1451 |
if (sockunion_family (&peer->su) == AF_INET) |
| 1452 |
bgp_md5_set (bm->sock, &peer->su.sin, NULL); |
| 1453 |
} |
| 1454 |
#endif /* HAVE_TCP_MD5SIG */ |
| 1455 |
|
|
Line 3382
Link Here
|
|
|
3418 |
#ifdef HAVE_TCP_MD5SIG |
| 3419 |
/* Set password for authenticating with the peer. */ |
| 3420 |
int |
| 3421 |
peer_password_set (struct peer *peer, const char *password) |
| 3422 |
{ |
| 3423 |
struct peer_group *group; |
| 3424 |
struct listnode *nn, *nnode; |
| 3425 |
int len = password ? strlen(password) : 0; |
| 3426 |
|
| 3427 |
if ((len < PEER_PASSWORD_MINLEN) || (len > PEER_PASSWORD_MAXLEN)) |
| 3428 |
return BGP_ERR_INVALID_VALUE; |
| 3429 |
|
| 3430 |
if (peer->password && strcmp (peer->password, password) == 0 |
| 3431 |
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
| 3432 |
return 0; |
| 3433 |
|
| 3434 |
SET_FLAG (peer->flags, PEER_FLAG_PASSWORD); |
| 3435 |
if (peer->password) |
| 3436 |
free (peer->password); |
| 3437 |
peer->password = strdup (password); |
| 3438 |
|
| 3439 |
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
| 3440 |
{ |
| 3441 |
if (peer->status == Established) |
| 3442 |
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); |
| 3443 |
else |
| 3444 |
BGP_EVENT_ADD (peer, BGP_Stop); |
| 3445 |
|
| 3446 |
if (sockunion_family (&peer->su) == AF_INET) |
| 3447 |
bgp_md5_set (bm->sock, &peer->su.sin, peer->password); |
| 3448 |
return 0; |
| 3449 |
} |
| 3450 |
|
| 3451 |
group = peer->group; |
| 3452 |
/* #42# LIST_LOOP (group->peer, peer, nn) */ |
| 3453 |
for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer)) |
| 3454 |
{ |
| 3455 |
if (peer->password && strcmp (peer->password, password) == 0) |
| 3456 |
continue; |
| 3457 |
|
| 3458 |
SET_FLAG (peer->flags, PEER_FLAG_PASSWORD); |
| 3459 |
if (peer->password) |
| 3460 |
free (peer->password); |
| 3461 |
peer->password = strdup (password); |
| 3462 |
|
| 3463 |
if (peer->status == Established) |
| 3464 |
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); |
| 3465 |
else |
| 3466 |
BGP_EVENT_ADD (peer, BGP_Stop); |
| 3467 |
|
| 3468 |
if (sockunion_family (&peer->su) == AF_INET) |
| 3469 |
bgp_md5_set (bm->sock, &peer->su.sin, peer->password); |
| 3470 |
} |
| 3471 |
|
| 3472 |
return 0; |
| 3473 |
} |
| 3474 |
|
| 3475 |
int |
| 3476 |
peer_password_unset (struct peer *peer) |
| 3477 |
{ |
| 3478 |
struct peer_group *group; |
| 3479 |
struct listnode *nn, *nnode; |
| 3480 |
|
| 3481 |
if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD) |
| 3482 |
&& ! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
| 3483 |
return 0; |
| 3484 |
|
| 3485 |
if (! CHECK_FLAG (peer->sflags, PEER_STATUS_GROUP)) |
| 3486 |
{ |
| 3487 |
if (peer_group_active (peer) |
| 3488 |
&& CHECK_FLAG (peer->group->conf->flags, PEER_FLAG_PASSWORD)) |
| 3489 |
return BGP_ERR_PEER_GROUP_HAS_THE_FLAG; |
| 3490 |
|
| 3491 |
if (peer->status == Established) |
| 3492 |
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); |
| 3493 |
else |
| 3494 |
BGP_EVENT_ADD (peer, BGP_Stop); |
| 3495 |
|
| 3496 |
if (sockunion_family (&peer->su) == AF_INET) |
| 3497 |
bgp_md5_set (bm->sock, &peer->su.sin, NULL); |
| 3498 |
|
| 3499 |
UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); |
| 3500 |
if (peer->password) |
| 3501 |
free (peer->password); |
| 3502 |
peer->password = NULL; |
| 3503 |
|
| 3504 |
return 0; |
| 3505 |
} |
| 3506 |
|
| 3507 |
UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); |
| 3508 |
if (peer->password) |
| 3509 |
free (peer->password); |
| 3510 |
peer->password = NULL; |
| 3511 |
|
| 3512 |
group = peer->group; |
| 3513 |
/* #42# LIST_LOOP (group->peer, peer, nn) */ |
| 3514 |
for (ALL_LIST_ELEMENTS (group->peer, nn, nnode, peer)) |
| 3515 |
{ |
| 3516 |
if (! CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)) |
| 3517 |
continue; |
| 3518 |
|
| 3519 |
if (peer->status == Established) |
| 3520 |
bgp_notify_send (peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_CEASE_CONFIG_CHANGE); |
| 3521 |
else |
| 3522 |
BGP_EVENT_ADD (peer, BGP_Stop); |
| 3523 |
|
| 3524 |
if (sockunion_family (&peer->su) == AF_INET) |
| 3525 |
bgp_md5_set (bm->sock, &peer->su.sin, NULL); |
| 3526 |
|
| 3527 |
UNSET_FLAG (peer->flags, PEER_FLAG_PASSWORD); |
| 3528 |
if (peer->password) |
| 3529 |
free (peer->password); |
| 3530 |
peer->password = NULL; |
| 3531 |
} |
| 3532 |
|
| 3533 |
return 0; |
| 3534 |
} |
| 3535 |
#endif /* HAVE_TCP_MD5SIG */ |
| 3536 |
|
|
Line 4419
Link Here
|
|
|
4574 |
#ifdef HAVE_TCP_MD5SIG |
| 4575 |
/* Password. */ |
| 4576 |
if (CHECK_FLAG (peer->flags, PEER_FLAG_PASSWORD)) |
| 4577 |
if (! peer_group_active (peer) |
| 4578 |
|| ! CHECK_FLAG (g_peer->flags, PEER_FLAG_PASSWORD) |
| 4579 |
|| strcmp (peer->password, g_peer->password) != 0) |
| 4580 |
vty_out (vty, " neighbor %s password %s%s", addr, peer->password, |
| 4581 |
VTY_NEWLINE); |
| 4582 |
#endif /* HAVE_TCP_MD5SIG */ |
| 4583 |
|
|
Line 4954
Link Here
|
|
|
5119 |
#ifdef HAVE_TCP_MD5SIG |
| 5120 |
bm->sock = -1; |
| 5121 |
#endif /* HAVE_TCP_MD5SIG */ |