* [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message
@ 2010-08-18 5:05 Changli Gao
2010-08-18 6:08 ` Eric Dumazet
2010-08-20 0:17 ` David Miller
0 siblings, 2 replies; 4+ messages in thread
From: Changli Gao @ 2010-08-18 5:05 UTC (permalink / raw)
To: Patrick McHardy; +Cc: David S. Miller, netfilter-devel, netdev, Changli Gao
Signed-off-by: Changli Gao <xiaosuo@gmail.com>
---
net/ipv4/netfilter/ipt_CLUSTERIP.c | 34 ++++++++++++++++++----------------
1 file changed, 18 insertions(+), 16 deletions(-)
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
index 3a43cf3..11c3534 100644
--- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
+++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
@@ -29,6 +29,7 @@
#include <net/netfilter/nf_conntrack.h>
#include <net/net_namespace.h>
#include <net/checksum.h>
+#include <net/ip.h>
#define CLUSTERIP_VERSION "0.8"
@@ -231,24 +232,25 @@ clusterip_hashfn(const struct sk_buff *skb,
{
const struct iphdr *iph = ip_hdr(skb);
unsigned long hashval;
- u_int16_t sport, dport;
+ u_int16_t sport = 0, dport = 0;
const u_int16_t *ports;
- switch (iph->protocol) {
- case IPPROTO_TCP:
- case IPPROTO_UDP:
- case IPPROTO_UDPLITE:
- case IPPROTO_SCTP:
- case IPPROTO_DCCP:
- case IPPROTO_ICMP:
- ports = (const void *)iph+iph->ihl*4;
- sport = ports[0];
- dport = ports[1];
- break;
- default:
- if (net_ratelimit())
- pr_info("unknown protocol %u\n", iph->protocol);
- sport = dport = 0;
+ if (!(iph->frag_off & htons(IP_MF|IP_OFFSET))) {
+ int poff;
+
+ poff = proto_ports_offset(iph->protocol);
+ if (poff >= 0) {
+ u16 _ports[2];
+ ports = skb_header_pointer(skb, iph->ihl * 4 + poff,
+ 4, _ports);
+ if (ports) {
+ sport = ports[0];
+ dport = ports[1];
+ }
+ } else {
+ if (net_ratelimit())
+ pr_info("unknown protocol %u\n", iph->protocol);
+ }
}
switch (config->hash_mode) {
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message
2010-08-18 5:05 [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message Changli Gao
@ 2010-08-18 6:08 ` Eric Dumazet
2010-08-18 6:16 ` Changli Gao
2010-08-20 0:17 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2010-08-18 6:08 UTC (permalink / raw)
To: Changli Gao; +Cc: Patrick McHardy, David S. Miller, netfilter-devel, netdev
Le mercredi 18 août 2010 à 13:05 +0800, Changli Gao a écrit :
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
> ---
> net/ipv4/netfilter/ipt_CLUSTERIP.c | 34 ++++++++++++++++++----------------
> 1 file changed, 18 insertions(+), 16 deletions(-)
> diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> index 3a43cf3..11c3534 100644
> --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c
> +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c
> @@ -29,6 +29,7 @@
> #include <net/netfilter/nf_conntrack.h>
> #include <net/net_namespace.h>
> #include <net/checksum.h>
> +#include <net/ip.h>
>
> #define CLUSTERIP_VERSION "0.8"
>
> @@ -231,24 +232,25 @@ clusterip_hashfn(const struct sk_buff *skb,
> {
> const struct iphdr *iph = ip_hdr(skb);
> unsigned long hashval;
> - u_int16_t sport, dport;
> + u_int16_t sport = 0, dport = 0;
> const u_int16_t *ports;
>
> - switch (iph->protocol) {
> - case IPPROTO_TCP:
> - case IPPROTO_UDP:
> - case IPPROTO_UDPLITE:
> - case IPPROTO_SCTP:
> - case IPPROTO_DCCP:
> - case IPPROTO_ICMP:
> - ports = (const void *)iph+iph->ihl*4;
> - sport = ports[0];
> - dport = ports[1];
> - break;
> - default:
> - if (net_ratelimit())
> - pr_info("unknown protocol %u\n", iph->protocol);
> - sport = dport = 0;
> + if (!(iph->frag_off & htons(IP_MF|IP_OFFSET))) {
This added test is not documented in your Changelog
Please dont add such things not telling why you do it.
I am not sure it is needed here, I dont know ipt_CLUSTERIP, but dont
defrag takes place before it ?
> + int poff;
> +
> + poff = proto_ports_offset(iph->protocol);
> + if (poff >= 0) {
> + u16 _ports[2];
> + ports = skb_header_pointer(skb, iph->ihl * 4 + poff,
> + 4, _ports);
> + if (ports) {
> + sport = ports[0];
> + dport = ports[1];
> + }
> + } else {
> + if (net_ratelimit())
> + pr_info("unknown protocol %u\n", iph->protocol);
> + }
> }
>
> switch (config->hash_mode) {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message
2010-08-18 6:08 ` Eric Dumazet
@ 2010-08-18 6:16 ` Changli Gao
0 siblings, 0 replies; 4+ messages in thread
From: Changli Gao @ 2010-08-18 6:16 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Patrick McHardy, David S. Miller, netfilter-devel, netdev
On Wed, Aug 18, 2010 at 2:08 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> This added test is not documented in your Changelog
>
> Please dont add such things not telling why you do it.
>
> I am not sure it is needed here, I dont know ipt_CLUSTERIP, but dont
> defrag takes place before it ?
You are right. ipt_CLUSTERIP relies on ip_conntrack, and defrag takes
place before it. Thanks. I'll post an update.
--
Regards,
Changli Gao(xiaosuo@gmail.com)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message
2010-08-18 5:05 [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message Changli Gao
2010-08-18 6:08 ` Eric Dumazet
@ 2010-08-20 0:17 ` David Miller
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2010-08-20 0:17 UTC (permalink / raw)
To: xiaosuo; +Cc: kaber, netfilter-devel, netdev
From: Changli Gao <xiaosuo@gmail.com>
Date: Wed, 18 Aug 2010 13:05:52 +0800
> Signed-off-by: Changli Gao <xiaosuo@gmail.com>
I applied the updated v2 version of this patch.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-08-20 0:17 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-18 5:05 [PATCH 6/8] netfilter: ipt_CLUSTERIP: use proto_ports_offset() to support AH message Changli Gao
2010-08-18 6:08 ` Eric Dumazet
2010-08-18 6:16 ` Changli Gao
2010-08-20 0:17 ` David Miller
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).