From 616d4b2e4ba67efff7a4fd1468b3c0f1ff2289a7 Mon Sep 17 00:00:00 2001 From: bizhiyuan Date: Fri, 24 Oct 2025 15:24:12 +0800 Subject: [PATCH] Refactor: Remove global booth_conf variable in transport.c. Refactor: Add braces around conditional blocks in transport.c. Refactor: Unindent various code blocks in transport.c. --- ...ces-around-conditional-blocks-in-tra.patch | 324 ++++++++++++++++++ ...global-booth_conf-variable-in-transp.patch | 206 +++++++++++ ...t-various-code-blocks-in-transport.c.patch | 182 ++++++++++ booth.spec | 11 +- 4 files changed, 722 insertions(+), 1 deletion(-) create mode 100644 backport-Refactor-Add-braces-around-conditional-blocks-in-tra.patch create mode 100644 backport-Refactor-Remove-global-booth_conf-variable-in-transp.patch create mode 100644 backport-Refactor-Unindent-various-code-blocks-in-transport.c.patch diff --git a/backport-Refactor-Add-braces-around-conditional-blocks-in-tra.patch b/backport-Refactor-Add-braces-around-conditional-blocks-in-tra.patch new file mode 100644 index 0000000..9d55d44 --- /dev/null +++ b/backport-Refactor-Add-braces-around-conditional-blocks-in-tra.patch @@ -0,0 +1,324 @@ +From 6b6d0ba26107dac44644847eca444462e5921e78 Mon Sep 17 00:00:00 2001 +From: Chris Lumens +Date: Fri, 25 Oct 2024 16:22:16 -0400 +Subject: [PATCH] Refactor: Add braces around conditional blocks in + transport.c. + +--- + src/transport.c | 115 ++++++++++++++++++++++++++++++++---------------- + 1 file changed, 77 insertions(+), 38 deletions(-) + +diff --git a/src/transport.c b/src/transport.c +index 7072640..c725897 100644 +--- a/src/transport.c ++++ b/src/transport.c +@@ -67,8 +67,10 @@ static void parse_rtattr(struct rtattr *tb[], + int max, struct rtattr *rta, int len) + { + while (RTA_OK(rta, len)) { +- if (rta->rta_type <= max) ++ if (rta->rta_type <= max) { + tb[rta->rta_type] = rta; ++ } ++ + rta = RTA_NEXT(rta,len); + } + } +@@ -102,13 +104,17 @@ static int find_address(struct booth_config *conf, + mask = ~( (1 << (8 - bits_left)) -1); + + FOREACH_NODE(conf, i, node) { +- if (family != node->family) ++ if (family != node->family) { + continue; ++ } ++ + n_a = node_to_addr_pointer(node); + +- for(matched = 0; matched < node->addrlen; matched++) +- if (ipaddr[matched] != n_a[matched]) ++ for (matched = 0; matched < node->addrlen; matched++) { ++ if (ipaddr[matched] != n_a[matched]) { + break; ++ } ++ } + + if (matched == node->addrlen) { + *address_bits_matched = matched * 8; +@@ -117,15 +123,18 @@ static int find_address(struct booth_config *conf, + break; + } + +- if (!fuzzy_allowed) ++ if (!fuzzy_allowed) { + continue; +- ++ } + + /* Check prefix, whole bytes */ +- if (matched < bytes) ++ if (matched < bytes) { + continue; +- if (matched * 8 < *address_bits_matched) ++ } ++ ++ if (matched * 8 < *address_bits_matched) { + continue; ++ } + + node_bits = n_a[bytes]; + ip_bits = ipaddr[bytes]; +@@ -158,14 +167,15 @@ static int _find_myself(struct booth_config *conf, int family, + int address_bits_matched; + + +- if (local) ++ if (local) { + goto found; +- ++ } + + me = NULL; + address_bits_matched = 0; +- if (mep) ++ if (mep) { + *mep = NULL; ++ } + fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (fd < 0) { + log_error("failed to create netlink socket"); +@@ -215,8 +225,9 @@ static int _find_myself(struct booth_config *conf, int family, + struct rtattr *tb[IFA_MAX+1]; + int len; + +- if (h->nlmsg_type == NLMSG_DONE) ++ if (h->nlmsg_type == NLMSG_DONE) { + goto out; ++ } + + if (h->nlmsg_type == NLMSG_ERROR) { + close(fd); +@@ -288,14 +299,17 @@ static int _find_myself(struct booth_config *conf, int family, + out: + close(fd); + +- if (!me) ++ if (!me) { + return 0; ++ } + + me->local = 1; + local = me; + found: +- if (mep) ++ if (mep) { + *mep = local; ++ } ++ + return 1; + } + +@@ -332,8 +346,9 @@ int check_boothc_header(struct boothc_header *h, int len_incl_data) + } + + +- if (len_incl_data < 0) ++ if (len_incl_data < 0) { + return 0; ++ } + + if (l != len_incl_data) { + log_error("length error - got %d, wanted %d", +@@ -350,14 +365,19 @@ static int do_read(int fd, void *buf, size_t count) + + while (off < count) { + rv = read(fd, (char *)buf + off, count - off); +- if (rv == 0) ++ if (rv == 0) { + return -1; +- if (rv == -1 && errno == EINTR) ++ } ++ if (rv == -1 && errno == EINTR) { + continue; +- if (rv == -1 && errno == EWOULDBLOCK) ++ } ++ if (rv == -1 && errno == EWOULDBLOCK) { + break; +- if (rv == -1) ++ } ++ if (rv == -1) { + return -1; ++ } ++ + off += rv; + } + return off; +@@ -369,8 +389,10 @@ static int do_write(int fd, void *buf, size_t count) + + retry: + rv = send(fd, (char *)buf + off, count, MSG_NOSIGNAL); +- if (rv == -1 && errno == EINTR) ++ if (rv == -1 && errno == EINTR) { + goto retry; ++ } ++ + /* If we cannot write _any_ data, we'd be in an (potential) loop. */ + if (rv <= 0) { + log_error("send failed: %s (%d)", strerror(errno), errno); +@@ -416,8 +438,9 @@ int read_client(struct client *req_cl) + fd = req_cl->fd; + rv = do_read(fd, msg+req_cl->offset, len-req_cl->offset); + if (rv < 0) { +- if (errno == ECONNRESET) ++ if (errno == ECONNRESET) { + log_debug("client connection reset for fd %d", fd); ++ } + return -1; + } + req_cl->offset += rv; +@@ -592,12 +615,14 @@ static int booth_tcp_init(void * unused __attribute__((unused))) + { + int rv; + +- if (get_local_id() < 0) ++ if (get_local_id() < 0) { + return -1; ++ } + + rv = setup_tcp_listener(0); +- if (rv < 0) ++ if (rv < 0) { + return rv; ++ } + + client_add(rv, booth_transport + TCP, + process_tcp_listener, NULL); +@@ -620,12 +645,14 @@ static int connect_nonb(int sockfd, const struct sockaddr *saptr, + } + + error = 0; +- if ( (n = connect(sockfd, saptr, salen)) < 0) +- if (errno != EINPROGRESS) +- return -1; ++ n = connect(sockfd, saptr, salen); ++ if (n < 0 && errno != EINPROGRESS) { ++ return -1; ++ } + +- if (n == 0) ++ if (n == 0) { + goto done; /* connect completed immediately */ ++ } + + FD_ZERO(&rset); + FD_SET(sockfd, &rset); +@@ -643,8 +670,9 @@ static int connect_nonb(int sockfd, const struct sockaddr *saptr, + + if (FD_ISSET(sockfd, &rset) || FD_ISSET(sockfd, &wset)) { + len = sizeof(error); +- if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) ++ if (getsockopt(sockfd, SOL_SOCKET, SO_ERROR, &error, &len) < 0) { + return -1; /* Solaris pending error */ ++ } + } else { + log_error("select error: sockfd not set"); + return -1; +@@ -671,8 +699,9 @@ static int booth_tcp_open(struct booth_site *to) + { + int s, rv; + +- if (to->tcp_fd >= STDERR_FILENO) ++ if (to->tcp_fd >= STDERR_FILENO) { + goto found; ++ } + + s = socket(to->family, SOCK_STREAM, 0); + if (s == -1) { +@@ -683,11 +712,12 @@ static int booth_tcp_open(struct booth_site *to) + + rv = connect_nonb(s, (struct sockaddr *)&to->sa6, to->saddrlen, 10); + if (rv == -1) { +- if( errno == ETIMEDOUT) ++ if (errno == ETIMEDOUT) { + log_error("connect to %s got a timeout", site_string(to)); +- else ++ } else { + log_error("connect to %s got an error: %s", site_string(to), + strerror(errno)); ++ } + goto error; + } + +@@ -697,8 +727,10 @@ found: + return 1; + + error: +- if (s >= 0) ++ if (s >= 0) { + close(s); ++ } ++ + return -1; + } + +@@ -783,8 +815,10 @@ static int booth_tcp_recv_auth(struct booth_config *conf, struct booth_site *fro + static int booth_tcp_close(struct booth_site *to) + { + if (to) { +- if (to->tcp_fd > STDERR_FILENO) ++ if (to->tcp_fd > STDERR_FILENO) { + close(to->tcp_fd); ++ } ++ + to->tcp_fd = -1; + } + return 0; +@@ -841,8 +875,10 @@ static int setup_udp_server(void) + return 0; + + ex: +- if (fd >= 0) ++ if (fd >= 0) { + close(fd); ++ } ++ + return -1; + } + +@@ -866,17 +902,19 @@ static void process_recv(struct booth_config *conf, int ci) + buffer, sizeof(buffer), + MSG_NOSIGNAL | MSG_DONTWAIT, + (struct sockaddr *)&sa, &sa_len); +- if (rv == -1) ++ if (rv == -1) { + return; ++ } + + rv = deliver_fn(conf, (void*) msg, rv); + if (rv > 0) { + if (getnameinfo((struct sockaddr *)&sa, sa_len, + buffer, sizeof(buffer), NULL, 0, +- NI_NUMERICHOST) == 0) ++ NI_NUMERICHOST) == 0) { + log_error("unknown sender: %08x (real: %s)", rv, buffer); +- else ++ } else { + log_error("unknown sender: %08x", rv); ++ } + } + } + +@@ -885,8 +923,9 @@ static int booth_udp_init(void *f) + int rv; + + rv = setup_udp_server(); +- if (rv < 0) ++ if (rv < 0) { + return rv; ++ } + + deliver_fn = f; + client_add(local->udp_fd, +-- +2.25.1 + diff --git a/backport-Refactor-Remove-global-booth_conf-variable-in-transp.patch b/backport-Refactor-Remove-global-booth_conf-variable-in-transp.patch new file mode 100644 index 0000000..bcd4286 --- /dev/null +++ b/backport-Refactor-Remove-global-booth_conf-variable-in-transp.patch @@ -0,0 +1,206 @@ +From 05c261e6fcd5d6a6dc573b9760840923726caf04 Mon Sep 17 00:00:00 2001 +From: Chris Lumens +Date: Fri, 25 Oct 2024 16:05:30 -0400 +Subject: [PATCH] Refactor: Remove global booth_conf variable in transport.c. + +Co-authored-by: Jan Pokorny +--- + src/attr.c | 2 +- + src/main.c | 4 ++-- + src/transport.c | 41 ++++++++++++++++++++++++++--------------- + src/transport.h | 16 ++++++++++++++-- + 4 files changed, 43 insertions(+), 20 deletions(-) + +diff --git a/src/attr.c b/src/attr.c +index 3faa888..0c68777 100644 +--- a/src/attr.c ++++ b/src/attr.c +@@ -211,7 +211,7 @@ int do_attr_command(struct booth_config *conf, cmd_request_t cmd) + goto out_close; + } + +- if (check_auth(site, msg, len)) { ++ if (check_auth(conf, site, msg, len)) { + log_error("%s failed to authenticate", site_string(site)); + rv = -1; + goto out_close; +diff --git a/src/main.c b/src/main.c +index cd69322..0114cf5 100644 +--- a/src/main.c ++++ b/src/main.c +@@ -725,7 +725,7 @@ static int query_get_string_answer(cmd_request_t cmd) + if (rv < 0) + goto out_close; + +- rv = tpt->recv_auth(site, &reply, sizeof(reply)); ++ rv = tpt->recv_auth(booth_conf, site, &reply, sizeof(reply)); + if (rv < 0) + goto out_close; + +@@ -828,7 +828,7 @@ redirect: + } + + read_more: +- rv = tpt->recv_auth(site, &reply, sizeof(reply)); ++ rv = tpt->recv_auth(booth_conf, site, &reply, sizeof(reply)); + if (rv < 0) { + /* print any errors depending on the code sent by the + * server */ +diff --git a/src/transport.c b/src/transport.c +index 63f3acc..6752e8c 100644 +--- a/src/transport.c ++++ b/src/transport.c +@@ -455,7 +455,7 @@ static void process_connection(struct booth_config *conf, int ci) + } + + header = (struct boothc_header *)msg; +- if (check_auth(NULL, msg, ntohl(header->length))) { ++ if (check_auth(conf, NULL, msg, ntohl(header->length))) { + errc = RLT_AUTH; + goto send_err; + } +@@ -747,7 +747,8 @@ static int booth_tcp_recv(struct booth_site *from, void *buf, int len) + return got; + } + +-static int booth_tcp_recv_auth(struct booth_site *from, void *buf, int len) ++static int booth_tcp_recv_auth(struct booth_config *conf, struct booth_site *from, ++ void *buf, int len) + { + int got, total; + int payload_len; +@@ -760,10 +761,13 @@ static int booth_tcp_recv_auth(struct booth_site *from, void *buf, int len) + } + total = got; + if (is_auth_req()) { +- got = booth_tcp_recv(from, (unsigned char *)buf+payload_len, sizeof(struct hmac)); +- if (got != sizeof(struct hmac) || check_auth(from, buf, len)) { ++ got = booth_tcp_recv(from, (unsigned char *)buf+payload_len, ++ sizeof(struct hmac)); ++ ++ if (got != sizeof(struct hmac) || check_auth(conf, from, buf, len)) { + return -1; + } ++ + total += got; + } + return total; +@@ -1024,11 +1028,12 @@ const struct booth_transport booth_transport[TRANSPORT_ENTRIES] = { + /* verify the validity of timestamp from the header + * the timestamp needs to be either greater than the one already + * recorded for the site or, and this is checked for clients, +- * not to be older than booth_conf->maxtimeskew ++ * not to be older than conf->maxtimeskew + * update the timestamp for the site, if this packet is from a + * site + */ +-static int verify_ts(struct booth_site *from, void *buf, int len) ++static int verify_ts(struct booth_config *conf, struct booth_site *from, ++ void *buf, int len) + { + struct boothc_header *h; + struct timeval tv, curr_tv, now; +@@ -1044,18 +1049,22 @@ static int verify_ts(struct booth_site *from, void *buf, int len) + if (from) { + curr_tv.tv_sec = from->last_secs; + curr_tv.tv_usec = from->last_usecs; +- if (timercmp(&tv, &curr_tv, >)) ++ if (timercmp(&tv, &curr_tv, >)) { + goto accept; ++ } ++ + log_warn("%s: packet timestamp older than previous one", + site_string(from)); + } + + gettimeofday(&now, NULL); +- now.tv_sec -= booth_conf->maxtimeskew; +- if (timercmp(&tv, &now, >)) ++ now.tv_sec -= conf->maxtimeskew; ++ if (timercmp(&tv, &now, >)) { + goto accept; ++ } ++ + log_error("%s: packet timestamp older than %d seconds", +- peer_string(from), booth_conf->maxtimeskew); ++ peer_string(from), conf->maxtimeskew); + return -1; + + accept: +@@ -1067,15 +1076,17 @@ accept: + } + #endif + +-int check_auth(struct booth_site *from, void *buf, int len) ++int check_auth(struct booth_config *conf, struct booth_site *from, void *buf, ++ int len) + { + int rv = 0; + #if HAVE_LIBGNUTLS || HAVE_LIBGCRYPT || HAVE_LIBMHASH + int payload_len; + struct hmac *hp; + +- if (!is_auth_req()) ++ if (!is_auth_req()) { + return 0; ++ } + + payload_len = len - sizeof(struct hmac); + if (payload_len < 0) { +@@ -1085,9 +1096,9 @@ int check_auth(struct booth_site *from, void *buf, int len) + } + hp = (struct hmac *)((unsigned char *)buf + payload_len); + rv = verify_hmac(buf, payload_len, ntohl(hp->hid), hp->hash, +- booth_conf->authkey, booth_conf->authkey_len); ++ conf->authkey, conf->authkey_len); + if (!rv) { +- rv = verify_ts(from, buf, len); ++ rv = verify_ts(conf, from, buf, len); + } + if (rv != 0) { + log_error("%s: failed to authenticate", peer_string(from)); +@@ -1148,7 +1159,7 @@ int message_recv(struct booth_config *conf, void *msg, int msglen) + return -1; + } + +- if (check_auth(source, msg, msglen)) { ++ if (check_auth(conf, source, msg, msglen)) { + log_error("%s failed to authenticate", site_string(source)); + source->sec_cnt++; + return -1; +diff --git a/src/transport.h b/src/transport.h +index 2784ce4..ce108e9 100644 +--- a/src/transport.h ++++ b/src/transport.h +@@ -50,7 +50,7 @@ struct booth_transport { + int (*send) (struct booth_config *, struct booth_site *, void *, int); + int (*send_auth) (struct booth_config *, struct booth_site *, void *, int); + int (*recv) (struct booth_site *, void *, int); +- int (*recv_auth) (struct booth_site *, void *, int); ++ int (*recv_auth) (struct booth_config *, struct booth_site *, void *, int); + int (*broadcast) (void *, int); + int (*broadcast_auth) (struct booth_config *, void *, int); + int (*close) (struct booth_site *); +@@ -141,6 +141,18 @@ int send_header_plus(struct booth_config *conf, int fd, + + #define send_client_msg(conf, fd, msg) send_data(conf, fd, msg, sendmsglen(msg)) + +-int check_auth(struct booth_site *from, void *buf, int len); ++/** ++ * @internal ++ * First stage of incoming datagram handling (authentication) ++ * ++ * @param[in,out] conf config object to refer to ++ * @param[in] from site structure of the sender ++ * @param[in] buf message to check ++ * @param[in] len length of @buf ++ * ++ * @return see #send_data and #do_write ++ */ ++int check_auth(struct booth_config *conf, struct booth_site *from, void *buf, ++ int len); + + #endif /* _TRANSPORT_H */ +-- +2.25.1 + diff --git a/backport-Refactor-Unindent-various-code-blocks-in-transport.c.patch b/backport-Refactor-Unindent-various-code-blocks-in-transport.c.patch new file mode 100644 index 0000000..43bb663 --- /dev/null +++ b/backport-Refactor-Unindent-various-code-blocks-in-transport.c.patch @@ -0,0 +1,182 @@ +From fd679976bb8fc1f550c9b7bd6641144b74c39e84 Mon Sep 17 00:00:00 2001 +From: Chris Lumens +Date: Fri, 25 Oct 2024 16:16:02 -0400 +Subject: [PATCH] Refactor: Unindent various code blocks in transport.c. + +When we have a condition with a bunch of code under it, these can often +be rewritten to invert the condition and exit which allows all the +previously indented code to be un-indented. This can make the resulting +code easier to follow. +--- + src/transport.c | 125 ++++++++++++++++++++++++++---------------------- + 1 file changed, 67 insertions(+), 58 deletions(-) + +diff --git a/src/transport.c b/src/transport.c +index 6752e8c..7072640 100644 +--- a/src/transport.c ++++ b/src/transport.c +@@ -20,6 +20,7 @@ + #include "b_config.h" + + #include ++#include + #include + #include + #include +@@ -191,7 +192,7 @@ static int _find_myself(struct booth_config *conf, int family, + return 0; + } + +- while (1) { ++ while (true) { + int status; + struct nlmsghdr *h; + struct iovec iov = { rcvbuf, sizeof(rcvbuf) }; +@@ -210,6 +211,10 @@ static int _find_myself(struct booth_config *conf, int family, + } + + for (h = (struct nlmsghdr *)rcvbuf; NLMSG_OK(h, status); h = NLMSG_NEXT(h, status)) { ++ struct ifaddrmsg *ifa = NULL; ++ struct rtattr *tb[IFA_MAX+1]; ++ int len; ++ + if (h->nlmsg_type == NLMSG_DONE) + goto out; + +@@ -219,60 +224,62 @@ static int _find_myself(struct booth_config *conf, int family, + return 0; + } + +- if (h->nlmsg_type == RTM_NEWADDR) { +- struct ifaddrmsg *ifa = NLMSG_DATA(h); +- struct rtattr *tb[IFA_MAX+1]; +- int len = h->nlmsg_len +- - NLMSG_LENGTH(sizeof(*ifa)); +- +- memset(tb, 0, sizeof(tb)); +- parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len); +- memset(ipaddr, 0, BOOTH_IPADDR_LEN); +- /* prefer IFA_LOCAL if it exists, for p-t-p +- * interfaces, otherwise use IFA_ADDRESS */ +- if (tb[IFA_LOCAL]) { +- memcpy(ipaddr, RTA_DATA(tb[IFA_LOCAL]), +- BOOTH_IPADDR_LEN); +- } else if (tb[IFA_ADDRESS]) { +- memcpy(ipaddr, RTA_DATA(tb[IFA_ADDRESS]), +- BOOTH_IPADDR_LEN); +- } else { +- log_error("failed to copy netlink addr"); +- close(fd); +- return 0; +- } ++ if (h->nlmsg_type != RTM_NEWADDR) { ++ continue; ++ } ++ ++ ifa = NLMSG_DATA(h); ++ len = h->nlmsg_len - NLMSG_LENGTH(sizeof(*ifa)); ++ ++ memset(tb, 0, sizeof(tb)); ++ parse_rtattr(tb, IFA_MAX, IFA_RTA(ifa), len); ++ memset(ipaddr, 0, BOOTH_IPADDR_LEN); ++ /* prefer IFA_LOCAL if it exists, for p-t-p ++ * interfaces, otherwise use IFA_ADDRESS */ ++ if (tb[IFA_LOCAL]) { ++ memcpy(ipaddr, RTA_DATA(tb[IFA_LOCAL]), ++ BOOTH_IPADDR_LEN); ++ } else if (tb[IFA_ADDRESS]) { ++ memcpy(ipaddr, RTA_DATA(tb[IFA_ADDRESS]), ++ BOOTH_IPADDR_LEN); ++ } else { ++ log_error("failed to copy netlink addr"); ++ close(fd); ++ return 0; ++ } + +- /* Try to find the exact address or the address with subnet matching. +- * The function find_address will be called for each address received +- * from NLMSG_DATA above. +- * The exact match will be preferred. If no exact match is found, +- * the function find_address will try to return another, most similar +- * address (with the longest possible number of same bytes). */ +- if (ifa->ifa_prefixlen > address_bits_matched) { +- find_address(conf, ipaddr, +- ifa->ifa_family, ifa->ifa_prefixlen, +- fuzzy_allowed, &me, &address_bits_matched); +- +- if (me) { +- log_debug("found myself at %s (%d bits matched)", +- site_string(me), address_bits_matched); +- } ++ /* Try to find the exact address or the address with subnet matching. ++ * The function find_address will be called for each address received ++ * from NLMSG_DATA above. ++ * The exact match will be preferred. If no exact match is found, ++ * the function find_address will try to return another, most similar ++ * address (with the longest possible number of same bytes). ++ */ ++ if (ifa->ifa_prefixlen > address_bits_matched) { ++ find_address(conf, ipaddr, ifa->ifa_family, ++ ifa->ifa_prefixlen, fuzzy_allowed, ++ &me, &address_bits_matched); ++ ++ if (me) { ++ log_debug("found myself at %s (%d bits matched)", ++ site_string(me), address_bits_matched); + } +- /* If the previous NLMSG_DATA calls have already allowed us +- * to find an address with address_bits_matched matching bits, +- * then no other better non-exact address can be found. +- * But we can still try to find an exact match, so let us +- * call the function find_address with disabled searching of +- * similar addresses (fuzzy_allowed == 0) */ +- else if (ifa->ifa_prefixlen == address_bits_matched) { +- find_address(conf, ipaddr, +- ifa->ifa_family, ifa->ifa_prefixlen, +- 0 /* fuzzy_allowed */, &me, &address_bits_matched); +- +- if (me) { +- log_debug("found myself at %s (exact match)", +- site_string(me)); +- } ++ } ++ /* If the previous NLMSG_DATA calls have already allowed us ++ * to find an address with address_bits_matched matching bits, ++ * then no other better non-exact address can be found. ++ * But we can still try to find an exact match, so let us ++ * call the function find_address with disabled searching of ++ * similar addresses (fuzzy_allowed == 0) ++ */ ++ else if (ifa->ifa_prefixlen == address_bits_matched) { ++ find_address(conf, ipaddr, ifa->ifa_family, ++ ifa->ifa_prefixlen, 0 /* fuzzy_allowed */, ++ &me, &address_bits_matched); ++ ++ if (me) { ++ log_debug("found myself at %s (exact match)", ++ site_string(me)); + } + } + } +@@ -944,11 +951,13 @@ static int booth_udp_broadcast_auth(struct booth_config *conf, void *buf, int le + + rvs = 0; + FOREACH_NODE(conf, i, site) { +- if (site != local) { +- rv = booth_udp_send(conf, site, buf, len); +- if (!rvs) { +- rvs = rv; +- } ++ if (site == local) { ++ continue; ++ } ++ ++ rv = booth_udp_send(conf, site, buf, len); ++ if (!rvs) { ++ rvs = rv; + } + } + +-- +2.25.1 + diff --git a/booth.spec b/booth.spec index ed11166..ea076c7 100644 --- a/booth.spec +++ b/booth.spec @@ -24,7 +24,7 @@ %bcond_with run_build_tests %bcond_with include_unit_test -%global release 11 +%global release 12 ## User and group to use for nonprivileged services (should be in sync with pacemaker) %global uname hacluster @@ -77,6 +77,10 @@ Patch25: backport-Coding-style-improvements-to-ticket.c.patch Patch26: backport-Refactor-Remove-global-booth_conf-variable-from-noti.patch Patch27: backport-Refactor-Remove-global-booth_conf-variable-from-list.patch Patch28: backport-Refactor-Remove-global-booth_conf-variable-from-netw.patch +Patch29: backport-Refactor-Remove-global-booth_conf-variable-in-transp.patch +Patch30: backport-Refactor-Unindent-various-code-blocks-in-transport.c.patch +Patch31: backport-Refactor-Add-braces-around-conditional-blocks-in-tra.patch + # direct build process dependencies BuildRequires: autoconf @@ -325,6 +329,11 @@ VERBOSE=1 make check %{_usr}/lib/ocf/resource.d/booth/sharedrsc %changelog +* Fri Oct 24 2025 bizhiyuan - 1.2-12 +- Refactor: Remove global booth_conf variable in transport.c. +- Refactor: Add braces around conditional blocks in transport.c. +- Refactor: Unindent various code blocks in transport.c. + * Wed Oct 22 2025 bizhiyuan - 1.2-11 - Remove global booth_conf variable from notify_client list_peers and network functions -- Gitee