Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F146359314
D31012.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D31012.diff
View Options
diff --git a/tests/sys/netinet/libalias/2_natout.c b/tests/sys/netinet/libalias/2_natout.c
--- a/tests/sys/netinet/libalias/2_natout.c
+++ b/tests/sys/netinet/libalias/2_natout.c
@@ -305,6 +305,60 @@
LibAliasUninit(la);
}
+ATF_TC_WITHOUT_HEAD(8_portrange);
+ATF_TC_BODY(8_portrange, dummy)
+{
+ struct libalias *la = LibAliasInit(NULL);
+ struct ip *po;
+ struct udphdr *uo;
+ uint16_t sport = 0x1234;
+ uint16_t dport = 0x5678;
+ uint16_t aport;
+
+ ATF_REQUIRE(la != NULL);
+ LibAliasSetAddress(la, masq);
+ LibAliasSetMode(la, 0, ~0);
+ po = ip_packet(0, 64);
+
+ LibAliasSetAliasPortRange(la, 0, 0); /* reinit like ipfw */
+ UDP_NAT_CHECK(po, uo, prv1, sport, ext, dport, masq);
+ aport = ntohs(uo->uh_sport);
+ ATF_CHECK(aport >= 0x8000);
+
+ /* Different larger range */
+ LibAliasSetAliasPortRange(la, 2000, 3000);
+ dport++;
+ UDP_NAT_CHECK(po, uo, prv1, sport, ext, dport, masq);
+ aport = ntohs(uo->uh_sport);
+ ATF_CHECK(aport >= 2000 && aport < 3000);
+
+ /* Different small range (contains two ports) */
+ LibAliasSetAliasPortRange(la, 4000, 4001);
+ dport++;
+ UDP_NAT_CHECK(po, uo, prv1, sport, ext, dport, masq);
+ aport = ntohs(uo->uh_sport);
+ ATF_CHECK(aport >= 4000 && aport <= 4001);
+
+ sport++;
+ UDP_NAT_CHECK(po, uo, prv1, sport, ext, dport, masq);
+ aport = ntohs(uo->uh_sport);
+ ATF_CHECK(aport >= 4000 && aport <= 4001);
+
+ /* Third port not available in the range */
+ sport++;
+ UDP_NAT_FAIL(po, uo, prv1, sport, ext, dport);
+
+ /* Back to normal */
+ LibAliasSetAliasPortRange(la, 0, 0);
+ dport++;
+ UDP_NAT_CHECK(po, uo, prv1, sport, ext, dport, masq);
+ aport = ntohs(uo->uh_sport);
+ ATF_CHECK(aport >= 0x8000);
+
+ free(po);
+ LibAliasUninit(la);
+}
+
ATF_TP_ADD_TCS(natout)
{
/* Use "dd if=/dev/random bs=2 count=1 | od -x" to reproduce */
@@ -317,6 +371,7 @@
ATF_TP_ADD_TC(natout, 5_sameport);
ATF_TP_ADD_TC(natout, 6_cleartable);
ATF_TP_ADD_TC(natout, 7_stress);
+ ATF_TP_ADD_TC(natout, 8_portrange);
return atf_no_error();
}
diff --git a/tests/sys/netinet/libalias/util.h b/tests/sys/netinet/libalias/util.h
--- a/tests/sys/netinet/libalias/util.h
+++ b/tests/sys/netinet/libalias/util.h
@@ -80,7 +80,7 @@
pip->ip_src = src; \
pip->ip_dst = dst; \
res = LibAliasOut(la, pip, len); \
- ATF_CHECK_MSG(res != PKT_ALIAS_OK), \
+ ATF_CHECK_MSG(res != PKT_ALIAS_OK, \
">%d< not met !PKT_ALIAS_OK", res); \
ATF_CHECK(addr_eq(src, pip->ip_src)); \
ATF_CHECK(addr_eq(dst, pip->ip_dst)); \
@@ -118,7 +118,7 @@
#define UDP_NAT_FAIL(p, u, si, sp, di, dp) do { \
u = set_udp(p, (sp), (dp)); \
- NAT_FAIL(p, (si), (mi)); \
+ NAT_FAIL(p, (si), (di)); \
} while(0)
#define UDP_UNNAT_CHECK(p, u, si, sp, mi, mp, di, dp) \
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Mar 3, 1:40 AM (6 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29176741
Default Alt Text
D31012.diff (2 KB)
Attached To
Mode
D31012: tests/libalias: Portrange
Attached
Detach File
Event Timeline
Log In to Comment