Date: Mon, 29 Aug 2005 10:15:38 GMT From: Victor Cruceru <soc-victor@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 82755 for review Message-ID: <200508291015.j7TAFcEa035147@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=82755 Change 82755 by soc-victor@soc-victor_82.76.158.176 on 2005/08/29 10:14:42 Handling for the corner situation of "duplicate UDP endpoints": distinct UDP endpoints with the same (local_address, local_port). This is for the deprecated udpTable which can't handle this case. Affected files ... .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_tcp_udp46/Makefile#5 edit .. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_tcp_udp46/udp46_snmp.c#3 edit Differences ... ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_tcp_udp46/Makefile#5 (text+ko) ==== @@ -37,7 +37,7 @@ WARNS?= 6 #Not having NDEBUG defined will enable assertions and a lot of output on stderr -#CFLAGS+= -DNDEBUG +CFLAGS+= -DNDEBUG XSYM= tcpMIB udpMIB ==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_tcp_udp46/udp46_snmp.c#3 (text+ko) ==== @@ -92,6 +92,33 @@ return result; } +/* + * Used to check if the enpoint is already in the oid list + * (for the deprecated table - it doesn't have the capability + * to handle duplicate endpoints) + * Returns 1 if the new endpoint is alreadsy in the table, + * 0 if it is not + */ +static +int check_duplicate_endpoint4(const struct xinpcb *inp) { + struct udp_index *_oid = NULL; + u_int i = 0; + assert(inp != NULL); + for (i = 0, _oid = tcp_udp46_state_g.udp4oids; + i < tcp_udp46_state_g.udp4_total; + i++, _oid++) { + if ( _oid->inp == NULL) { + continue; + } + if ( inp->xi_inp.inp_laddr.s_addr == _oid->inp->xi_inp.inp_laddr.s_addr + && inp->xi_inp.inp_lport == _oid->inp->xi_inp.inp_lport) { + return (1); /*duplicate endpoint found*/ + } + } + return (0); + +} + int fetch_udp(void) { @@ -197,15 +224,20 @@ continue; } if ((inp->xi_inp.inp_vflag & INP_IPV4) == INP_IPV4 && inp->xi_inp.inp_lport != 0) { - oid->inp = inp; - oid->index.len = 5; - inaddr = ntohl(inp->xi_inp.inp_laddr.s_addr); - oid->index.subs[0] = (inaddr >> 24) & 0xff; - oid->index.subs[1] = (inaddr >> 16) & 0xff; - oid->index.subs[2] = (inaddr >> 8) & 0xff; - oid->index.subs[3] = (inaddr >> 0) & 0xff; - oid->index.subs[4] = ntohs(inp->xi_inp.inp_lport); - oid++; + if (check_duplicate_endpoint4(inp) == 1) { + assert(tcp_udp46_state_g.udp4_total > 1); + tcp_udp46_state_g.udp4_total--; + } else { + oid->inp = inp; + oid->index.len = 5; + inaddr = ntohl(inp->xi_inp.inp_laddr.s_addr); + oid->index.subs[0] = (inaddr >> 24) & 0xff; + oid->index.subs[1] = (inaddr >> 16) & 0xff; + oid->index.subs[2] = (inaddr >> 8) & 0xff; + oid->index.subs[3] = (inaddr >> 0) & 0xff; + oid->index.subs[4] = ntohs(inp->xi_inp.inp_lport); + oid++; + } } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508291015.j7TAFcEa035147>