Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src Pull up following revision(s) (requested by rmind in tick...
details: https://anonhg.NetBSD.org/src/rev/77ac24dd0ef7
branches: netbsd-6
changeset: 775443:77ac24dd0ef7
user: riz <riz%NetBSD.org@localhost>
date: Sun Nov 18 21:48:56 2012 +0000
description:
Pull up following revision(s) (requested by rmind in ticket #679):
sys/net/npf/npf_session.c: revision 1.18
usr.sbin/npf/npftest/npftest.c: revision 1.6
usr.sbin/npf/npftest/npftest.c: revision 1.7
usr.sbin/npf/npftest/npftest.c: revision 1.8
usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c: revision 1.2
usr.sbin/npf/npftest/libnpftest/npf_state_test.c: revision 1.3
usr.sbin/npf/npftest/libnpftest/npf_table_test.c: revision 1.5
sys/net/npf/npf_alg_icmp.c: revision 1.13
usr.sbin/npf/npftest/libnpftest/npf_rule_test.c: revision 1.2
usr.sbin/npf/npftest/npfstream.c: revision 1.4
usr.sbin/npf/npftest/libnpftest/npf_processor_test.c: revision 1.3
npftest:
- Do not stop running other tests, if some tests fail.
- Fix some endianness bugs in the test cases.
Tested on sparc64 by martin@, all tests pass.
Add two new command line options to help integration into ATF:
-L lists the available test cases, -T executes a single named test.
Fix printf format
Mark npf_session_worker as __dead.
More __dead
npf_icmp_uniqid: split into npf_icmp_uniqid4() and npf_icmp_uniqid6() parts.
diffstat:
sys/net/npf/npf_alg_icmp.c | 207 ++++++++++--------
sys/net/npf/npf_session.c | 6 +-
usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c | 13 +-
usr.sbin/npf/npftest/libnpftest/npf_processor_test.c | 123 ++++------
usr.sbin/npf/npftest/libnpftest/npf_rule_test.c | 12 +-
usr.sbin/npf/npftest/libnpftest/npf_state_test.c | 7 +-
usr.sbin/npf/npftest/libnpftest/npf_table_test.c | 97 +++++---
usr.sbin/npf/npftest/npfstream.c | 4 +-
usr.sbin/npf/npftest/npftest.c | 96 ++++++--
9 files changed, 308 insertions(+), 257 deletions(-)
diffs (truncated from 1057 to 300 lines):
diff -r ac5013e1749f -r 77ac24dd0ef7 sys/net/npf/npf_alg_icmp.c
--- a/sys/net/npf/npf_alg_icmp.c Sun Nov 18 21:45:08 2012 +0000
+++ b/sys/net/npf/npf_alg_icmp.c Sun Nov 18 21:48:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_alg_icmp.c,v 1.8.4.4 2012/09/13 22:33:05 riz Exp $ */
+/* $NetBSD: npf_alg_icmp.c,v 1.8.4.5 2012/11/18 21:48:56 riz Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_alg_icmp.c,v 1.8.4.4 2012/09/13 22:33:05 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_alg_icmp.c,v 1.8.4.5 2012/11/18 21:48:56 riz Exp $");
#include <sys/param.h>
#include <sys/module.h>
@@ -151,109 +151,110 @@
}
/*
- * npf_icmp_uniqid: retrieve unique identifiers - either ICMP query ID
+ * npf_icmp{4,6}_uniqid: retrieve unique identifiers - either ICMP query ID
* or TCP/UDP ports of the original packet, which is embedded.
*/
+
static bool
-npf_icmp_uniqid(const int npcinf, const int type,
- npf_cache_t *npc, nbuf_t *nbuf, void *n_ptr)
+npf_icmp4_uniqid(const int type, npf_cache_t *npc, nbuf_t *nbuf, void *n_ptr)
{
- struct icmp *ic;
- struct icmp6_hdr *ic6;
- u_int offby;
+ struct icmp *ic;
+ u_int offby;
- if (npcinf & NPC_IP4) {
- /* Per RFC 792. */
- switch (type) {
- case ICMP_UNREACH:
- case ICMP_SOURCEQUENCH:
- case ICMP_REDIRECT:
- case ICMP_TIMXCEED:
- case ICMP_PARAMPROB:
- /* Should contain original IP header. */
- offby = offsetof(struct icmp, icmp_ip);
- if ((n_ptr = nbuf_advance(&nbuf, n_ptr, offby)) == NULL) {
- return false;
- }
- /* Fetch into the cache. */
- if (!npf_fetch_ip(npc, nbuf, n_ptr)) {
- return false;
- }
- switch (npf_cache_ipproto(npc)) {
- case IPPROTO_TCP:
- return npf_fetch_tcp(npc, nbuf, n_ptr);
- case IPPROTO_UDP:
- return npf_fetch_udp(npc, nbuf, n_ptr);
- default:
- return false;
- }
- return true;
+ /* Per RFC 792. */
+ switch (type) {
+ case ICMP_UNREACH:
+ case ICMP_SOURCEQUENCH:
+ case ICMP_REDIRECT:
+ case ICMP_TIMXCEED:
+ case ICMP_PARAMPROB:
+ /* Should contain original IP header. */
+ offby = offsetof(struct icmp, icmp_ip);
+ if ((n_ptr = nbuf_advance(&nbuf, n_ptr, offby)) == NULL) {
+ return false;
+ }
+ /* Fetch into the cache. */
+ if (!npf_fetch_ip(npc, nbuf, n_ptr)) {
+ return false;
+ }
+ switch (npf_cache_ipproto(npc)) {
+ case IPPROTO_TCP:
+ return npf_fetch_tcp(npc, nbuf, n_ptr);
+ case IPPROTO_UDP:
+ return npf_fetch_udp(npc, nbuf, n_ptr);
+ default:
+ return false;
+ }
+ return true;
- case ICMP_ECHOREPLY:
- case ICMP_ECHO:
- case ICMP_TSTAMP:
- case ICMP_TSTAMPREPLY:
- case ICMP_IREQ:
- case ICMP_IREQREPLY:
- /* Should contain ICMP query ID. */
- ic = &npc->npc_l4.icmp;
- offby = offsetof(struct icmp, icmp_id);
- if (nbuf_advfetch(&nbuf, &n_ptr, offby,
- sizeof(uint16_t), &ic->icmp_id)) {
- return false;
- }
- npc->npc_info |= NPC_ICMP_ID;
- return true;
- default:
- break;
+ case ICMP_ECHOREPLY:
+ case ICMP_ECHO:
+ case ICMP_TSTAMP:
+ case ICMP_TSTAMPREPLY:
+ case ICMP_IREQ:
+ case ICMP_IREQREPLY:
+ /* Should contain ICMP query ID. */
+ ic = &npc->npc_l4.icmp;
+ offby = offsetof(struct icmp, icmp_id);
+ if (nbuf_advfetch(&nbuf, &n_ptr, offby,
+ sizeof(uint16_t), &ic->icmp_id)) {
+ return false;
}
- /* No unique IDs. */
- return false;
+ npc->npc_info |= NPC_ICMP_ID;
+ return true;
+ default:
+ break;
}
- if (npcinf & NPC_IP6) {
- switch (type) {
- /* Per RFC 4443. */
- case ICMP6_DST_UNREACH:
- case ICMP6_PACKET_TOO_BIG:
- case ICMP6_TIME_EXCEEDED:
- case ICMP6_PARAM_PROB:
- /* Should contain original IP header. */
- offby = sizeof(struct icmp6_hdr);
- if ((n_ptr = nbuf_advance(&nbuf, n_ptr, offby)) == NULL) {
- return false;
- }
- /* Fetch into the cache. */
- if (!npf_fetch_ip(npc, nbuf, n_ptr)) {
- return false;
- }
- switch (npf_cache_ipproto(npc)) {
- case IPPROTO_TCP:
- return npf_fetch_tcp(npc, nbuf, n_ptr);
- case IPPROTO_UDP:
- return npf_fetch_udp(npc, nbuf, n_ptr);
- default:
- return false;
- }
- return true;
+ /* No unique IDs. */
+ return false;
+}
+
+static bool
+npf_icmp6_uniqid(const int type, npf_cache_t *npc, nbuf_t *nbuf, void *n_ptr)
+{
+ struct icmp6_hdr *ic6;
+ u_int offby;
- case ICMP6_ECHO_REQUEST:
- case ICMP6_ECHO_REPLY:
- /* Should contain ICMP query ID. */
- ic6 = &npc->npc_l4.icmp6;
- offby = offsetof(struct icmp6_hdr, icmp6_id);
- if (nbuf_advfetch(&nbuf, &n_ptr, offby,
- sizeof(uint16_t), &ic6->icmp6_id)) {
- return false;
- }
- npc->npc_info |= NPC_ICMP_ID;
- return true;
+ /* Per RFC 4443. */
+ switch (type) {
+ case ICMP6_DST_UNREACH:
+ case ICMP6_PACKET_TOO_BIG:
+ case ICMP6_TIME_EXCEEDED:
+ case ICMP6_PARAM_PROB:
+ /* Should contain original IP header. */
+ offby = sizeof(struct icmp6_hdr);
+ if ((n_ptr = nbuf_advance(&nbuf, n_ptr, offby)) == NULL) {
+ return false;
+ }
+ /* Fetch into the cache. */
+ if (!npf_fetch_ip(npc, nbuf, n_ptr)) {
+ return false;
+ }
+ switch (npf_cache_ipproto(npc)) {
+ case IPPROTO_TCP:
+ return npf_fetch_tcp(npc, nbuf, n_ptr);
+ case IPPROTO_UDP:
+ return npf_fetch_udp(npc, nbuf, n_ptr);
default:
- break;
+ return false;
}
- /* No unique IDs. */
- return false;
+ return true;
+
+ case ICMP6_ECHO_REQUEST:
+ case ICMP6_ECHO_REPLY:
+ /* Should contain ICMP query ID. */
+ ic6 = &npc->npc_l4.icmp6;
+ offby = offsetof(struct icmp6_hdr, icmp6_id);
+ if (nbuf_advfetch(&nbuf, &n_ptr, offby,
+ sizeof(uint16_t), &ic6->icmp6_id)) {
+ return false;
+ }
+ npc->npc_info |= NPC_ICMP_ID;
+ return true;
+ default:
+ break;
}
- /* Whatever protocol that may have been ... */
+ /* No unique IDs. */
return false;
}
@@ -287,6 +288,8 @@
npfa_icmp_session(npf_cache_t *npc, nbuf_t *nbuf, void *keyptr)
{
npf_cache_t *key = keyptr;
+ bool ret;
+
KASSERT(key->npc_info == 0);
/* IP + ICMP? Get unique identifiers from ICMP packet. */
@@ -306,10 +309,22 @@
return false;
}
- /* Fetch relevant data into the separate ("key") cache. */
+ /*
+ * Fetch relevant data into the separate ("key") cache.
+ */
struct icmp *ic = &npc->npc_l4.icmp;
- if (!npf_icmp_uniqid(npc->npc_info & NPC_IP46, ic->icmp_type,
- key, nbuf, n_ptr)) {
+
+ if (npf_iscached(npc, NPC_IP4)) {
+ ret = npf_icmp4_uniqid(ic->icmp_type, key, nbuf, n_ptr);
+ } else if (npf_iscached(npc, NPC_IP6)) {
+ KASSERT(offsetof(struct icmp, icmp_id) ==
+ offsetof(struct icmp6_hdr, icmp6_id));
+ ret = npf_icmp6_uniqid(ic->icmp_type, key, nbuf, n_ptr);
+ } else {
+ ret = false;
+ }
+
+ if (!ret) {
return false;
}
diff -r ac5013e1749f -r 77ac24dd0ef7 sys/net/npf/npf_session.c
--- a/sys/net/npf/npf_session.c Sun Nov 18 21:45:08 2012 +0000
+++ b/sys/net/npf/npf_session.c Sun Nov 18 21:48:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_session.c,v 1.10.4.6 2012/08/13 17:49:52 riz Exp $ */
+/* $NetBSD: npf_session.c,v 1.10.4.7 2012/11/18 21:48:56 riz Exp $ */
/*-
* Copyright (c) 2010-2012 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_session.c,v 1.10.4.6 2012/08/13 17:49:52 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_session.c,v 1.10.4.7 2012/11/18 21:48:56 riz Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -194,7 +194,7 @@
static void sess_tracking_stop(void);
static void npf_session_destroy(npf_session_t *);
-static void npf_session_worker(void *);
+static void npf_session_worker(void *) __dead;
/*
* npf_session_sys{init,fini}: initialise/destroy session handling structures.
diff -r ac5013e1749f -r 77ac24dd0ef7 usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c
--- a/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c Sun Nov 18 21:45:08 2012 +0000
+++ b/usr.sbin/npf/npftest/libnpftest/npf_nbuf_test.c Sun Nov 18 21:48:56 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: npf_nbuf_test.c,v 1.1.4.2 2012/06/26 00:07:18 riz Exp $ */
+/* $NetBSD: npf_nbuf_test.c,v 1.1.4.3 2012/11/18 21:48:56 riz Exp $ */
/*
* NPF nbuf interface test.
@@ -157,20 +157,17 @@
{
struct mbuf *m1, *m2;
char *bufa, *bufb;
+ bool fail = false;
m1 = mbuf_random_len(MBUF_CHAIN_LEN);
bufa = mbuf_getstring(m1);
bufb = parse_nbuf_chain(m1, m1->m_data);
Home |
Main Index |
Thread Index |
Old Index