This patch is based off of: http://patchwork.quagga.net/patch/1334/
I was not sure how to indicate that in the patch file. Do we have a 'methodology' for this? donald On Fri, Sep 11, 2015 at 7:56 AM, Donald Sharp <[email protected]> wrote: > All functions that call zclient_read_header immediately turn around > and check to ensure that the version and marker fields are correct > Move this code into zclient_read_header > > Signed-off-by: Donald Sharp <[email protected]> > --- > bgpd/bgp_nexthop.c | 24 +++--------------------- > lib/zclient.c | 8 ++++++++ > pimd/pim_zlookup.c | 9 +-------- > 3 files changed, 12 insertions(+), 29 deletions(-) > > diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c > index c74beba..20302e3 100644 > --- a/bgpd/bgp_nexthop.c > +++ b/bgpd/bgp_nexthop.c > @@ -809,13 +809,7 @@ zlookup_read (void) > zlog_err("%s: zserv_read_header() failed", __func__); > return NULL; > } > - if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) > - { > - zlog_err("%s: socket %d version mismatch, marker %d, version %d", > - __func__, zlookup->sock, marker, version); > - return NULL; > - } > - > + > /* XXX: not doing anything with raddr */ > raddr.s_addr = stream_get_ipv4 (s); > metric = stream_getl (s); > @@ -918,13 +912,7 @@ zlookup_read_ipv6 (void) > zlog_err("%s: zserv_read_header() failed", __func__); > return NULL; > } > - if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) > - { > - zlog_err("%s: socket %d version mismatch, marker %d, version %d", > - __func__, zlookup->sock, marker, version); > - return NULL; > - } > - > + > /* XXX: not actually doing anything with raddr */ > stream_get (&raddr, s, 16); > > @@ -1065,13 +1053,7 @@ bgp_import_check (struct prefix *p, u_int32_t > *igpmetric, > zlog_err("%s: zserv_read_header() failed", __func__); > return 0; > } > - if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) > - { > - zlog_err("%s: socket %d version mismatch, marker %d, version %d", > - __func__, zlookup->sock, marker, version); > - return 0; > - } > - > + > /* XXX: not using addr */ > addr.s_addr = stream_get_ipv4 (s); > metric = stream_getl (s); > diff --git a/lib/zclient.c b/lib/zclient.c > index c1bdd8f..a9dbd0d 100644 > --- a/lib/zclient.c > +++ b/lib/zclient.c > @@ -314,6 +314,14 @@ zclient_read_header (struct stream *s, int sock, > u_int16_t *size, u_char *marker > *version = stream_getc (s); > *vrf_id = stream_getw (s); > *cmd = stream_getw (s); > + > + if (*version != ZSERV_VERSION || *marker != ZEBRA_HEADER_MARKER) > + { > + zlog_err("%s: socket %d version mismatch, marker %d, version %d", > + __func__, sock, *marker, *version); > + return -1; > + } > + > return 0; > } > > diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c > index fae8f81..67896d9 100644 > --- a/pimd/pim_zlookup.c > +++ b/pimd/pim_zlookup.c > @@ -196,14 +196,7 @@ static int zclient_read_nexthop(struct zclient > *zlookup, > zclient_lookup_failed(zlookup); > return -3; > } > - > - if (version != ZSERV_VERSION || marker != ZEBRA_HEADER_MARKER) { > - zlog_err("%s: socket %d version mismatch, marker %d, version %d", > - __func__, zlookup->sock, marker, version); > - zclient_lookup_failed(zlookup); > - return -4; > - } > - > + > if (command != ZEBRA_IPV4_NEXTHOP_LOOKUP_MRIB) { > zlog_err("%s: socket %d command mismatch: %d", > __func__, zlookup->sock, command); > -- > 1.7.10.4 > >
_______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
