From owner-p4-projects@FreeBSD.ORG Mon Aug 29 10:15:42 2005 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CB8C016A423; Mon, 29 Aug 2005 10:15:39 +0000 (GMT) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 87A5B16A422 for ; Mon, 29 Aug 2005 10:15:39 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 37FAE43D45 for ; Mon, 29 Aug 2005 10:15:39 +0000 (GMT) (envelope-from soc-victor@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id j7TAFdG3035150 for ; Mon, 29 Aug 2005 10:15:39 GMT (envelope-from soc-victor@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id j7TAFcEa035147 for perforce@freebsd.org; Mon, 29 Aug 2005 10:15:38 GMT (envelope-from soc-victor@freebsd.org) Date: Mon, 29 Aug 2005 10:15:38 GMT Message-Id: <200508291015.j7TAFcEa035147@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to soc-victor@freebsd.org using -f From: Victor Cruceru To: Perforce Change Reviews Cc: Subject: PERFORCE change 82755 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Aug 2005 10:15:42 -0000 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++; + } } }