"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/bgpd/session.c" between
openbgpd-6.7p0.tar.gz and openbgpd-6.8p0.tar.gz

About: OpenBGPD is a Border Gateway Protocol (BGP) daemon which manages the network routing tables. Its main purpose is to exchange information concerning "network reachability" with other BGP systems.

session.c  (openbgpd-6.7p0):session.c  (openbgpd-6.8p0)
/* $OpenBSD: session.c,v 1.400 2020/04/23 16:13:11 claudio Exp $ */ /* $OpenBSD: session.c,v 1.402 2020/06/27 07:24:42 bket Exp $ */
/* /*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org> * Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
* Copyright (c) 2017 Peter van Dijk <peter.van.dijk@powerdns.com> * Copyright (c) 2017 Peter van Dijk <peter.van.dijk@powerdns.com>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies. * copyright notice and this permission notice appear in all copies.
* *
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
skipping to change at line 519 skipping to change at line 519
for (; j < idx_mrts; j++) for (; j < idx_mrts; j++)
if (pfd[j].revents & POLLOUT) if (pfd[j].revents & POLLOUT)
mrt_write(mrt_l[j - idx_peers]); mrt_write(mrt_l[j - idx_peers]);
for (; j < i; j++) for (; j < i; j++)
control_dispatch_msg(&pfd[j], &ctl_cnt, &conf->peers); control_dispatch_msg(&pfd[j], &ctl_cnt, &conf->peers);
} }
RB_FOREACH_SAFE(p, peer_head, &conf->peers, next) { RB_FOREACH_SAFE(p, peer_head, &conf->peers, next) {
RB_REMOVE(peer_head, &conf->peers, p); RB_REMOVE(peer_head, &conf->peers, p);
strlcpy(p->conf.shutcomm, strlcpy(p->conf.reason,
"bgpd shutting down", "bgpd shutting down",
sizeof(p->conf.shutcomm)); sizeof(p->conf.reason));
session_stop(p, ERR_CEASE_ADMIN_DOWN); session_stop(p, ERR_CEASE_ADMIN_DOWN);
timer_remove_all(p); timer_remove_all(p);
free(p); free(p);
} }
while ((m = LIST_FIRST(&mrthead)) != NULL) { while ((m = LIST_FIRST(&mrthead)) != NULL) {
mrt_clean(m); mrt_clean(m);
LIST_REMOVE(m, entry); LIST_REMOVE(m, entry);
free(m); free(m);
} }
skipping to change at line 2249 skipping to change at line 2249
int int
parse_notification(struct peer *peer) parse_notification(struct peer *peer)
{ {
u_char *p; u_char *p;
u_int16_t datalen; u_int16_t datalen;
u_int8_t errcode; u_int8_t errcode;
u_int8_t subcode; u_int8_t subcode;
u_int8_t capa_code; u_int8_t capa_code;
u_int8_t capa_len; u_int8_t capa_len;
size_t shutcomm_len; size_t reason_len;
u_int8_t i; u_int8_t i;
/* just log */ /* just log */
p = peer->rbuf->rptr; p = peer->rbuf->rptr;
p += MSGSIZE_HEADER_MARKER; p += MSGSIZE_HEADER_MARKER;
memcpy(&datalen, p, sizeof(datalen)); memcpy(&datalen, p, sizeof(datalen));
datalen = ntohs(datalen); datalen = ntohs(datalen);
p = peer->rbuf->rptr; p = peer->rbuf->rptr;
p += MSGSIZE_HEADER; /* header is already checked */ p += MSGSIZE_HEADER; /* header is already checked */
skipping to change at line 2350 skipping to change at line 2350
if (errcode == ERR_OPEN && subcode == ERR_OPEN_OPT) { if (errcode == ERR_OPEN && subcode == ERR_OPEN_OPT) {
session_capa_ann_none(peer); session_capa_ann_none(peer);
return (1); return (1);
} }
if (errcode == ERR_CEASE && if (errcode == ERR_CEASE &&
(subcode == ERR_CEASE_ADMIN_DOWN || (subcode == ERR_CEASE_ADMIN_DOWN ||
subcode == ERR_CEASE_ADMIN_RESET)) { subcode == ERR_CEASE_ADMIN_RESET)) {
if (datalen > 1) { if (datalen > 1) {
shutcomm_len = *p++; reason_len = *p++;
datalen--; datalen--;
if (datalen < shutcomm_len) { if (datalen < reason_len) {
log_peer_warnx(&peer->conf, log_peer_warnx(&peer->conf,
"received truncated shutdown reason"); "received truncated shutdown reason");
return (0); return (0);
} }
if (shutcomm_len > SHUT_COMM_LEN - 1) { if (reason_len > REASON_LEN - 1) {
log_peer_warnx(&peer->conf, log_peer_warnx(&peer->conf,
"received overly long shutdown reason"); "received overly long shutdown reason");
return (0); return (0);
} }
memcpy(peer->stats.last_shutcomm, p, shutcomm_len); memcpy(peer->stats.last_reason, p, reason_len);
peer->stats.last_shutcomm[shutcomm_len] = '\0'; peer->stats.last_reason[reason_len] = '\0';
log_peer_warnx(&peer->conf, log_peer_warnx(&peer->conf,
"received shutdown reason: \"%s\"", "received shutdown reason: \"%s\"",
log_shutcomm(peer->stats.last_shutcomm)); log_reason(peer->stats.last_reason));
p += shutcomm_len; p += reason_len;
datalen -= shutcomm_len; datalen -= reason_len;
} }
} }
return (0); return (0);
} }
int int
parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen, u_int32_t *as) parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen, u_int32_t *as)
{ {
u_char *capa_val; u_char *capa_val;
skipping to change at line 2739 skipping to change at line 2739
log_sockaddr((struct sockaddr *) log_sockaddr((struct sockaddr *)
&la->sa, la->sa_len)); &la->sa, la->sa_len));
TAILQ_REMOVE(conf->listen_addrs, la, TAILQ_REMOVE(conf->listen_addrs, la,
entry); entry);
close(la->fd); close(la->fd);
free(la); free(la);
} }
} }
/* add new listeners */ /* add new listeners */
while ((la = TAILQ_FIRST(nconf->listen_addrs)) != TAILQ_CONCAT(conf->listen_addrs, nconf->listen_addrs,
NULL) { entry);
TAILQ_REMOVE(nconf->listen_addrs, la, entry);
TAILQ_INSERT_TAIL(conf->listen_addrs, la,
entry);
}
setup_listeners(listener_cnt); setup_listeners(listener_cnt);
free_config(nconf); free_config(nconf);
nconf = NULL; nconf = NULL;
pending_reconf = 0; pending_reconf = 0;
log_info("SE reconfigured"); log_info("SE reconfigured");
imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0, imsg_compose(ibuf_main, IMSG_RECONF_DONE, 0, 0,
-1, NULL, 0); -1, NULL, 0);
break; break;
case IMSG_IFINFO: case IMSG_IFINFO:
skipping to change at line 3229 skipping to change at line 3225
if (imsg_compose(ibuf_main, IMSG_DEMOTE, p->conf.id, 0, -1, if (imsg_compose(ibuf_main, IMSG_DEMOTE, p->conf.id, 0, -1,
&msg, sizeof(msg)) == -1) &msg, sizeof(msg)) == -1)
fatalx("imsg_compose error"); fatalx("imsg_compose error");
p->demoted += level; p->demoted += level;
} }
void void
session_stop(struct peer *peer, u_int8_t subcode) session_stop(struct peer *peer, u_int8_t subcode)
{ {
char data[SHUT_COMM_LEN]; char data[REASON_LEN];
size_t datalen; size_t datalen;
size_t shutcomm_len; size_t reason_len;
char *communication; char *communication;
datalen = 0; datalen = 0;
communication = peer->conf.shutcomm; communication = peer->conf.reason;
if ((subcode == ERR_CEASE_ADMIN_DOWN || if ((subcode == ERR_CEASE_ADMIN_DOWN ||
subcode == ERR_CEASE_ADMIN_RESET) subcode == ERR_CEASE_ADMIN_RESET)
&& communication && *communication) { && communication && *communication) {
shutcomm_len = strlen(communication); reason_len = strlen(communication);
if (shutcomm_len > SHUT_COMM_LEN - 1) { if (reason_len > REASON_LEN - 1) {
log_peer_warnx(&peer->conf, log_peer_warnx(&peer->conf,
"trying to send overly long shutdown reason"); "trying to send overly long shutdown reason");
} else { } else {
data[0] = shutcomm_len; data[0] = reason_len;
datalen = shutcomm_len + sizeof(data[0]); datalen = reason_len + sizeof(data[0]);
memcpy(data + 1, communication, shutcomm_len); memcpy(data + 1, communication, reason_len);
} }
} }
switch (peer->state) { switch (peer->state) {
case STATE_OPENSENT: case STATE_OPENSENT:
case STATE_OPENCONFIRM: case STATE_OPENCONFIRM:
case STATE_ESTABLISHED: case STATE_ESTABLISHED:
session_notification(peer, ERR_CEASE, subcode, data, datalen); session_notification(peer, ERR_CEASE, subcode, data, datalen);
break; break;
default: default:
/* session not open, no need to send notification */ /* session not open, no need to send notification */
 End of changes. 15 change blocks. 
26 lines changed or deleted 22 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)