From owner-svn-src-stable@freebsd.org Thu Apr 19 10:11:40 2018 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 367D1F95099; Thu, 19 Apr 2018 10:11:40 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DD3546CF88; Thu, 19 Apr 2018 10:11:39 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id BE4843D2; Thu, 19 Apr 2018 10:11:39 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w3JABdHk003006; Thu, 19 Apr 2018 10:11:39 GMT (envelope-from ae@FreeBSD.org) Received: (from ae@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w3JABd5s003004; Thu, 19 Apr 2018 10:11:39 GMT (envelope-from ae@FreeBSD.org) Message-Id: <201804191011.w3JABd5s003004@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ae set sender to ae@FreeBSD.org using -f From: "Andrey V. Elsukov" Date: Thu, 19 Apr 2018 10:11:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r332765 - in stable/11/sys/netpfil/ipfw: . nat64 X-SVN-Group: stable-11 X-SVN-Commit-Author: ae X-SVN-Commit-Paths: in stable/11/sys/netpfil/ipfw: . nat64 X-SVN-Commit-Revision: 332765 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Apr 2018 10:11:40 -0000 Author: ae Date: Thu Apr 19 10:11:39 2018 New Revision: 332765 URL: https://svnweb.freebsd.org/changeset/base/332765 Log: MFC r316825: Use address of specific union member instead of whole union address to fix PVS-Studio warnings. MFC r316826: Avoid undefined behavior. The 'pktid' variable is modified while being used twice between sequence points, probably due to htonl() is macro. Modified: stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c stable/11/sys/netpfil/ipfw/nat64/nat64stl.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c ============================================================================== --- stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c Thu Apr 19 10:08:28 2018 (r332764) +++ stable/11/sys/netpfil/ipfw/ip_fw_table_algo.c Thu Apr 19 10:11:39 2018 (r332765) @@ -526,7 +526,8 @@ ta_dump_radix_tentry(void *ta_state, struct table_info #ifdef INET6 } else { xn = (struct radix_addr_xentry *)e; - memcpy(&tent->k, &xn->addr6.sin6_addr, sizeof(struct in6_addr)); + memcpy(&tent->k.addr6, &xn->addr6.sin6_addr, + sizeof(struct in6_addr)); tent->masklen = xn->masklen; tent->subtype = AF_INET6; tent->v.kidx = xn->value; @@ -1381,7 +1382,7 @@ ta_dump_chash_tentry(void *ta_state, struct table_info tent->v.kidx = ent->value; #ifdef INET6 } else { - memcpy(&tent->k, &ent->a.a6, sizeof(struct in6_addr)); + memcpy(&tent->k.addr6, &ent->a.a6, sizeof(struct in6_addr)); tent->masklen = cfg->mask6; tent->subtype = AF_INET6; tent->v.kidx = ent->value; @@ -3984,7 +3985,8 @@ ta_dump_kfib_tentry_int(struct sockaddr *paddr, struct if (paddr->sa_family == AF_INET6) { addr6 = (struct sockaddr_in6 *)paddr; mask6 = (struct sockaddr_in6 *)pmask; - memcpy(&tent->k, &addr6->sin6_addr, sizeof(struct in6_addr)); + memcpy(&tent->k.addr6, &addr6->sin6_addr, + sizeof(struct in6_addr)); len = 128; if (mask6 != NULL) len = contigmask((uint8_t *)&mask6->sin6_addr, 128); Modified: stable/11/sys/netpfil/ipfw/nat64/nat64stl.c ============================================================================== --- stable/11/sys/netpfil/ipfw/nat64/nat64stl.c Thu Apr 19 10:08:28 2018 (r332764) +++ stable/11/sys/netpfil/ipfw/nat64/nat64stl.c Thu Apr 19 10:11:39 2018 (r332765) @@ -75,7 +75,8 @@ nat64stl_log(struct pfloghdr *plog, struct mbuf *m, sa plog->action = PF_NAT; plog->dir = PF_IN; plog->rulenr = htonl(kidx); - plog->subrulenr = htonl(++pktid); + pktid++; + plog->subrulenr = htonl(pktid); plog->ruleset[0] = '\0'; strlcpy(plog->ifname, "NAT64STL", sizeof(plog->ifname)); ipfw_bpf_mtap2(plog, PFLOG_HDRLEN, m);