Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Feb 2020 19:48:52 +0000
From:      "neel_neelc.org (Neel Chauhan)" <phabric-noreply@FreeBSD.org>
To:        Phabricator <phabric-noreply@FreeBSD.org>
Cc:        freebsd-net@freebsd.org
Subject:   [Differential] D23794: nat64lsn: When allocating, check if we already allocated pg in nat64lsn_alloc_pg()
Message-ID:  <differential-rev-PHID-DREV-ookq7jrtmoe3xzcxelnj-req@reviews.freebsd.org>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
neel_neelc.org created this revision.
neel_neelc.org added a project: network.
Herald added subscribers: Contributor Reviews (base), melifaro, ae, imp.

REVISION SUMMARY
  nat64lsn: When allocating, check if we already allocated pg in nat64lsn_alloc_pg().
  
  Submitted by: Neel Chauhan <neel AT neelc DOT org>

REPOSITORY
  rS FreeBSD src repository

REVISION DETAIL
  https://reviews.freebsd.org/D23794

AFFECTED FILES
  sys/netpfil/ipfw/nat64/nat64lsn.c

EMAIL PREFERENCES
  https://reviews.freebsd.org/settings/panel/emailpreferences/

To: neel_neelc.org
Cc: imp, ae, melifaro, freebsd-net-list, #contributor_reviews_base, mmacy, kpraveen.lkml_gmail.com, marcnarc_gmail.com, simonvella_gmail.com, novice_techie.com, tommi.pernila_iki.fi

[-- Attachment #2 --]
diff --git a/sys/netpfil/ipfw/nat64/nat64lsn.c b/sys/netpfil/ipfw/nat64/nat64lsn.c
--- a/sys/netpfil/ipfw/nat64/nat64lsn.c
+++ b/sys/netpfil/ipfw/nat64/nat64lsn.c
@@ -1143,26 +1143,27 @@
 	if (link == NULL)
 		return (PG_ERROR(1));
 
-	/*
-	 * TODO: check that we did not already allocated PG in
-	 *	 previous call.
-	 */
-
 	ret = 0;
 	alias = link->alias;
 	/* Find place in pgchunk where PG can be added */
 	switch (ji->proto) {
 	case IPPROTO_TCP:
+		if (!ck_pr_load_ptr(&alias->tcp_pg))
+			break;
 		ret = nat64lsn_alloc_proto_pg(cfg, alias,
 		    &alias->tcp_chunkmask, alias->tcp_pgmask,
 		    alias->tcp, &alias->tcp_pg, ji->proto);
 		break;
 	case IPPROTO_UDP:
+		if (!ck_pr_load_ptr(&alias->udp_pg))
+			break;
 		ret = nat64lsn_alloc_proto_pg(cfg, alias,
 		    &alias->udp_chunkmask, alias->udp_pgmask,
 		    alias->udp, &alias->udp_pg, ji->proto);
 		break;
 	case IPPROTO_ICMP:
+		if (!ck_pr_load_ptr(&alias->icmp_pg))
+			break;
 		ret = nat64lsn_alloc_proto_pg(cfg, alias,
 		    &alias->icmp_chunkmask, alias->icmp_pgmask,
 		    alias->icmp, &alias->icmp_pg, ji->proto);


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?differential-rev-PHID-DREV-ookq7jrtmoe3xzcxelnj-req>