From: Patrick McHardy <kaber@trash.net>
To: Laszlo Attila Toth <panther@balabit.hu>
Cc: netfilter-devel@vger.kernel.org, jengelh@medozas.de
Subject: Re: [resend net-next] socket: Added 'transparent' option
Date: Thu, 04 Jun 2009 15:34:18 +0200 [thread overview]
Message-ID: <4A27CD5A.6040303@trash.net> (raw)
In-Reply-To: <1244122013-25970-1-git-send-email-panther@balabit.hu>
Laszlo Attila Toth wrote:
> +++ b/include/linux/netfilter/xt_socket.h
> @@ -0,0 +1,8 @@
> +#ifndef _XT_SOCKET_H_match
> +#define _XT_SOCKET_H_match
> +
> +struct xt_socket_match_info1 {
> + __u8 transparent;
> +};
Please use a bitmask.
> static bool
> -socket_mt(const struct sk_buff *skb, const struct xt_match_param *par)
> +socket_match(const struct sk_buff *skb, const struct xt_match_param *par,
> + bool check_transparent)
> {
> const struct iphdr *iph = ip_hdr(skb);
> struct udphdr _hdr, *hp = NULL;
> @@ -142,10 +145,22 @@ socket_mt(const struct sk_buff *skb, const struct xt_match_param *par)
> saddr, daddr, sport, dport, par->in, false);
> if (sk != NULL) {
> bool wildcard = (sk->sk_state != TCP_TIME_WAIT && inet_sk(sk)->rcv_saddr == 0);
> + bool transparent = (sk->sk_state != TCP_TIME_WAIT &&
> + inet_sk(sk)->transparent) ||
> + (sk->sk_state == TCP_TIME_WAIT &&
> + inet_twsk(sk)->tw_transparent);
> + const struct xt_socket_match_info1 *info = NULL;
This is not particulary well readable. Please do the initializations
seperately from the definitions.
> +
> + if (check_transparent)
> + info = par->matchinfo;
How about just passing par->matchinfo to socket_match()?
> nf_tproxy_put_sock(sk);
> +
> if (wildcard)
> sk = NULL;
> + else if (check_transparent && info->transparent &&
> + !transparent)
> + sk = NULL;
Please add a comment what this is doing exactly. And why do the lookup
at all in this case?
next prev parent reply other threads:[~2009-06-04 13:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-04 13:26 [resend net-next] socket: Added 'transparent' option Laszlo Attila Toth
2009-06-04 13:26 ` [resend iptables] " Laszlo Attila Toth
2009-06-04 13:34 ` Patrick McHardy [this message]
2009-06-04 14:55 ` [resend net-next] " Jan Engelhardt
2009-06-04 15:27 ` Laszlo Attila Toth
2009-06-04 16:03 ` Jan Engelhardt
2009-06-04 16:08 ` Patrick McHardy
2009-06-05 13:06 ` Laszlo Attila Toth
2009-06-08 12:30 ` [resend2] Socket match with transparent option, take 2 Laszlo Attila Toth
2009-06-08 12:30 ` [resend2 net-next] socket: added mtinfo with 'transparent' flag Laszlo Attila Toth
2009-06-08 12:30 ` [resend2 iptables] socket match: new revision, match transparent sockets Laszlo Attila Toth
2009-06-09 12:50 ` [resend2 net-next] socket: added mtinfo with 'transparent' flag Patrick McHardy
2009-06-09 13:11 ` [net-next] " Laszlo Attila Toth
2009-06-09 13:18 ` Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4A27CD5A.6040303@trash.net \
--to=kaber@trash.net \
--cc=jengelh@medozas.de \
--cc=netfilter-devel@vger.kernel.org \
--cc=panther@balabit.hu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).