lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sat, 29 Mar 2008 16:24:18 +0100 (CET)
From:	Jan Engelhardt <jengelh@...putergmbh.de>
To:	Ilpo Järvinen <ilpo.jarvinen@...sinki.fi>
cc:	Patrick Hardy <kaber@...sh.net>, netfilter-devel@...r.kernel.org,
	David Miller <davem@...emloft.net>,
	Netdev <netdev@...r.kernel.org>
Subject: Re: [PATCH] [NETFILTER] xt_TCPMSS: combine nearly identical
 reverse_mtu4/6


On Saturday 2008-03-29 14:25, Ilpo Järvinen wrote:
>
> Added tcpmss_reverse_mtu, only flowi setup and family differ
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...sinki.fi>
> ---
> net/netfilter/xt_TCPMSS.c |   34 ++++++++++++++--------------------
> 1 files changed, 14 insertions(+), 20 deletions(-)

How about this one instead?

commit 1143bd2cbcddb9fcdbffea6a2edfde42dca5bb46
Author: Jan Engelhardt <jengelh@...putergmbh.de>
Date:   Sat Mar 29 16:20:13 2008 +0100

     [NETFILTER]: Collapse tcpmss_reverse_mtu{4,6} into one function

     Signed-off-by: Jan Engelhardt <jengelh@...putergmbh.de>
---
  net/netfilter/xt_TCPMSS.c |   44 ++++++++++++++------------------------------
  1 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
index 217e2b6..2e3fe8e 100644
--- a/net/netfilter/xt_TCPMSS.c
+++ b/net/netfilter/xt_TCPMSS.c
@@ -147,15 +147,19 @@ tcpmss_mangle_packet(struct sk_buff *skb,
  	return TCPOLEN_MSS;
  }

-static u_int32_t tcpmss_reverse_mtu4(const struct iphdr *iph)
+static u_int32_t tcpmss_reverse_mtu(const struct sk_buff *skb,
+                                    unsigned int family)
  {
-	struct flowi fl = {
-		.fl4_dst = iph->saddr,
-	};
+	struct flowi fl = {};
  	const struct nf_afinfo *ai;
  	struct rtable *rt = NULL;
  	u_int32_t mtu     = ~0U;

+	if (family == AF_INET)
+		fl.fl4_dst = ip_hdr(skb)->saddr;
+	else
+		fl.fl6_dst = ipv6_hdr(skb)->saddr;
+
  	rcu_read_lock();
  	ai = nf_get_afinfo(AF_INET);
  	if (ai != NULL)
@@ -178,9 +182,10 @@ tcpmss_tg4(struct sk_buff *skb, const struct net_device *in,
  	__be16 newlen;
  	int ret;

-	ret = tcpmss_mangle_packet(skb, targinfo, tcpmss_reverse_mtu4(iph),
-				   iph->ihl * 4,
-				   sizeof(*iph) + sizeof(struct tcphdr));
+	ret = tcpmss_mangle_packet(skb, targinfo,
+	                           tcpmss_reverse_mtu(skb, AF_INET),
+	                           iph->ihl * 4,
+	                           sizeof(*iph) + sizeof(struct tcphdr));
  	if (ret < 0)
  		return NF_DROP;
  	if (ret > 0) {
@@ -193,28 +198,6 @@ tcpmss_tg4(struct sk_buff *skb, const struct net_device *in,
  }

  #if defined(CONFIG_IP6_NF_IPTABLES) || defined(CONFIG_IP6_NF_IPTABLES_MODULE)
-static u_int32_t tcpmss_reverse_mtu6(const struct ipv6hdr *iph)
-{
-	struct flowi fl = {
-		.fl6_dst = iph->saddr,
-	};
-	const struct nf_afinfo *ai;
-	struct rtable *rt = NULL;
-	u_int32_t mtu     = ~0U;
-
-	rcu_read_lock();
-	ai = nf_get_afinfo(AF_INET6);
-	if (ai != NULL)
-		ai->route((struct dst_entry **)&rt, &fl);
-	rcu_read_unlock();
-
-	if (rt != NULL) {
-		mtu = dst_mtu(&rt->u.dst);
-		dst_release(&rt->u.dst);
-	}
-	return mtu;
-}
-
  static unsigned int
  tcpmss_tg6(struct sk_buff *skb, const struct net_device *in,
             const struct net_device *out, unsigned int hooknum,
@@ -229,7 +212,8 @@ tcpmss_tg6(struct sk_buff *skb, const struct net_device *in,
  	tcphoff = ipv6_skip_exthdr(skb, sizeof(*ipv6h), &nexthdr);
  	if (tcphoff < 0)
  		return NF_DROP;
-	ret = tcpmss_mangle_packet(skb, targinfo, tcpmss_reverse_mtu6(ipv6h),
+	ret = tcpmss_mangle_packet(skb, targinfo,
+	                           tcpmss_reverse_mtu(skb, AF_INET6),
  				   tcphoff,
  				   sizeof(*ipv6h) + sizeof(struct tcphdr));
  	if (ret < 0)
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ