[Git][NTPsec/ntpsec][master] Record ucast/bcast/mcast flags in a packet's buffer when received...
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Dec 7 12:46:02 UTC 2015
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
813f50ee by Eric S. Raymond at 2015-12-07T07:40:47Z
Record ucast/bcast/mcast flags in a packet's buffer when received...
...rather than computing them in ntp_monitor.c, in order to avoid having
to keep data (the socket fd) that cannot be serialized into a replay file.
The SOCKET fd field is now used only for purging fd-associated recvbufs (which
will be bypassed in replay mode) and for diagnostic messages on the refclock
side of things.
- - - - -
3 changed files:
- include/recvbuff.h
- ntpd/ntp_io.c
- ntpd/ntp_monitor.c
Changes:
=====================================
include/recvbuff.h
=====================================
--- a/include/recvbuff.h
+++ b/include/recvbuff.h
@@ -61,6 +61,7 @@ struct recvbuf {
#endif
endpt * dstadr; /* address pkt arrived on */
SOCKET fd; /* fd on which it was received */
+ int cast_flags; /* unicast/broadcast/manycast mode */
l_fp recv_time; /* time of arrival */
void (*receiver)(struct recvbuf *); /* callback */
size_t recv_length; /* number of octets received */
=====================================
ntpd/ntp_io.c
=====================================
--- a/ntpd/ntp_io.c
+++ b/ntpd/ntp_io.c
@@ -3282,6 +3282,7 @@ read_refclock_packet(
rb->recv_length = buflen;
rb->recv_peer = rp->srcclock;
rb->dstadr = 0;
+ rb->cast_flags = 0;
rb->fd = fd;
rb->recv_time = ts;
rb->receiver = rp->clock_recv;
@@ -3540,6 +3541,9 @@ read_network_packet(
* put it on the full list and do bookkeeping.
*/
rb->dstadr = itf;
+ rb->cast_flags = (uint8_t)(((rb->dstadr->flags &
+ INT_MCASTOPEN) && rb->fd == rb->dstadr->fd) ? MDF_MCAST
+ : rb->fd == rb->dstadr->bfd ? MDF_BCAST : MDF_UCAST);
rb->fd = fd;
#ifdef USE_PACKET_TIMESTAMP
/* pick up a network time stamp if possible */
=====================================
ntpd/ntp_monitor.c
=====================================
--- a/ntpd/ntp_monitor.c
+++ b/ntpd/ntp_monitor.c
@@ -478,9 +478,7 @@ ntp_monitor(
memcpy(&mon->rmtadr, &rbufp->recv_srcadr, sizeof(mon->rmtadr));
mon->vn_mode = VN_MODE(version, mode);
mon->lcladr = rbufp->dstadr;
- mon->cast_flags = (uint8_t)(((rbufp->dstadr->flags &
- INT_MCASTOPEN) && rbufp->fd == mon->lcladr->fd) ? MDF_MCAST
- : rbufp->fd == mon->lcladr->bfd ? MDF_BCAST : MDF_UCAST);
+ mon->cast_flags = rbufp->cast_flags;
/*
* Drop him into front of the hash table. Also put him on top of
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/813f50ee4285d17350c306fa8b3a4369d6dd2018
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20151207/8b81f74a/attachment.html>
More information about the vc
mailing list