diff options
author | Lawrence Teo <lteo@cvs.openbsd.org> | 2014-07-10 03:18:00 +0000 |
---|---|---|
committer | Lawrence Teo <lteo@cvs.openbsd.org> | 2014-07-10 03:18:00 +0000 |
commit | 1ddd2bb9b60e97bb4705f747421ba7f1c11f1b6c (patch) | |
tree | 96c32f75a6fe85a6b078fcded781e7dfc2b40a30 /sys/netinet | |
parent | f2aacc7c2d52053d548c057a2c53c168fb490ca0 (diff) |
Simplify the way divert(4) sends packets to userspace: Instead of
unnecessarily allocating an mbuf tag to store the divert port, just pass
the divert port directly to divert_packet() or divert6_packet() as an
argument.
includes a style fix pointed out by bluhm@
ok bluhm@ henning@ reyk@
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/ip_divert.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_divert.h | 4 |
2 files changed, 5 insertions, 13 deletions
diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 0acd87f7b65..de1ad481518 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.22 2014/04/23 14:43:14 florian Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.23 2014/07/10 03:17:59 lteo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -189,12 +189,11 @@ fail: } int -divert_packet(struct mbuf *m, int dir) +divert_packet(struct mbuf *m, int dir, u_int16_t divert_port) { struct inpcb *inp; struct socket *sa = NULL; struct sockaddr_in addr; - struct pf_divert *divert; inp = NULL; divstat.divs_ipackets++; @@ -205,15 +204,8 @@ divert_packet(struct mbuf *m, int dir) return (0); } - divert = pf_find_divert(m); - if (divert == NULL) { - divstat.divs_errors++; - m_freem(m); - return (0); - } - TAILQ_FOREACH(inp, &divbtable.inpt_queue, inp_queue) { - if (inp->inp_lport != divert->port) + if (inp->inp_lport != divert_port) continue; if (inp->inp_divertfl == 0) break; diff --git a/sys/netinet/ip_divert.h b/sys/netinet/ip_divert.h index 488c12814ef..7294a48aaf5 100644 --- a/sys/netinet/ip_divert.h +++ b/sys/netinet/ip_divert.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.h,v 1.5 2014/04/23 14:43:14 florian Exp $ */ +/* $OpenBSD: ip_divert.h,v 1.6 2014/07/10 03:17:59 lteo Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -55,7 +55,7 @@ extern struct divstat divstat; void divert_init(void); void divert_input(struct mbuf *, ...); -int divert_packet(struct mbuf *, int); +int divert_packet(struct mbuf *, int, u_int16_t); int divert_sysctl(int *, u_int, void *, size_t *, void *, size_t); int divert_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *, struct proc *); |