From: Patrick McHardy <kaber@trash.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
Maillist netdev <netdev@oss.sgi.com>
Subject: Re: [XFRM]: Fix ICMP tempsel
Date: Sun, 20 Feb 2005 06:30:42 +0100 [thread overview]
Message-ID: <42182082.9060301@trash.net> (raw)
In-Reply-To: <20050219184351.GB10773@gondor.apana.org.au>
[-- Attachment #1: Type: text/plain, Size: 500 bytes --]
Herbert Xu wrote:
> I know this comment is probably a bit late but why didn't we simply put
> type/code into sport/dport in struct flowi instead of introducing the
> monstrosities of xfrm_flowi_sport/xfrm_flowi_dport?
>
> Something like
>
> struct {
> __u16 type;
> __u16 code;
> } icmpt;
>
> would've done (and still would do) the trick, no?
Here is an updated patch that kills xfrm_flowi_{sport,dport}.
I've checked around, there seems to be nothing that relies
on type and code beeing u8.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 4116 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2005/02/20 06:19:59+01:00 kaber@coreworks.de
# [XFRM]: Fix ICMP tempsel
#
# The selector ports are initialized to fl_ip_sport/fl_ip_dport instead
# of xfrm_flowi_sport(fl)/xfrm_flowi_dport(fl). This is wrong for ICMP,
# type and code should be stored in sport and dport, in struct flowi both
# are contained in fl_ip_sport.
#
# This patch adjusts struct flowi to store ICMP type/code in sport/dport
# and kills xfrm_flowi_sport/dport instead of changing xfrm_init_tempsel(),
# as suggested by Herbert Xu.
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# include/net/xfrm.h
# 2005/02/20 06:19:50+01:00 kaber@coreworks.de +4 -44
# [XFRM]: Fix ICMP tempsel
#
# The selector ports are initialized to fl_ip_sport/fl_ip_dport instead
# of xfrm_flowi_sport(fl)/xfrm_flowi_dport(fl). This is wrong for ICMP,
# type and code should be stored in sport and dport, in struct flowi both
# are contained in fl_ip_sport.
#
# This patch adjusts struct flowi to store ICMP type/code in sport/dport
# and kills xfrm_flowi_sport/dport instead of changing xfrm_init_tempsel(),
# as suggested by Herbert Xu.
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# include/net/flow.h
# 2005/02/20 06:19:50+01:00 kaber@coreworks.de +2 -2
# [XFRM]: Fix ICMP tempsel
#
# The selector ports are initialized to fl_ip_sport/fl_ip_dport instead
# of xfrm_flowi_sport(fl)/xfrm_flowi_dport(fl). This is wrong for ICMP,
# type and code should be stored in sport and dport, in struct flowi both
# are contained in fl_ip_sport.
#
# This patch adjusts struct flowi to store ICMP type/code in sport/dport
# and kills xfrm_flowi_sport/dport instead of changing xfrm_init_tempsel(),
# as suggested by Herbert Xu.
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/include/net/flow.h b/include/net/flow.h
--- a/include/net/flow.h 2005-02-20 06:20:34 +01:00
+++ b/include/net/flow.h 2005-02-20 06:20:34 +01:00
@@ -58,8 +58,8 @@
} ports;
struct {
- __u8 type;
- __u8 code;
+ __u16 type;
+ __u16 code;
} icmpt;
struct {
diff -Nru a/include/net/xfrm.h b/include/net/xfrm.h
--- a/include/net/xfrm.h 2005-02-20 06:20:34 +01:00
+++ b/include/net/xfrm.h 2005-02-20 06:20:34 +01:00
@@ -417,53 +417,13 @@
return 1;
}
-static __inline__
-u16 xfrm_flowi_sport(struct flowi *fl)
-{
- u16 port;
- switch(fl->proto) {
- case IPPROTO_TCP:
- case IPPROTO_UDP:
- case IPPROTO_SCTP:
- port = fl->fl_ip_sport;
- break;
- case IPPROTO_ICMP:
- case IPPROTO_ICMPV6:
- port = htons(fl->fl_icmp_type);
- break;
- default:
- port = 0; /*XXX*/
- }
- return port;
-}
-
-static __inline__
-u16 xfrm_flowi_dport(struct flowi *fl)
-{
- u16 port;
- switch(fl->proto) {
- case IPPROTO_TCP:
- case IPPROTO_UDP:
- case IPPROTO_SCTP:
- port = fl->fl_ip_dport;
- break;
- case IPPROTO_ICMP:
- case IPPROTO_ICMPV6:
- port = htons(fl->fl_icmp_code);
- break;
- default:
- port = 0; /*XXX*/
- }
- return port;
-}
-
static inline int
__xfrm4_selector_match(struct xfrm_selector *sel, struct flowi *fl)
{
return addr_match(&fl->fl4_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(&fl->fl4_src, &sel->saddr, sel->prefixlen_s) &&
- !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
- !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
+ !((fl->fl_ip_dport ^ sel->dport) & sel->dport_mask) &&
+ !((fl->fl_ip_sport ^ sel->sport) & sel->sport_mask) &&
(fl->proto == sel->proto || !sel->proto) &&
(fl->oif == sel->ifindex || !sel->ifindex);
}
@@ -473,8 +433,8 @@
{
return addr_match(&fl->fl6_dst, &sel->daddr, sel->prefixlen_d) &&
addr_match(&fl->fl6_src, &sel->saddr, sel->prefixlen_s) &&
- !((xfrm_flowi_dport(fl) ^ sel->dport) & sel->dport_mask) &&
- !((xfrm_flowi_sport(fl) ^ sel->sport) & sel->sport_mask) &&
+ !((fl->fl_ip_dport ^ sel->dport) & sel->dport_mask) &&
+ !((fl->fl_ip_sport ^ sel->sport) & sel->sport_mask) &&
(fl->proto == sel->proto || !sel->proto) &&
(fl->oif == sel->ifindex || !sel->ifindex);
}
next prev parent reply other threads:[~2005-02-20 5:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-19 11:43 [XFRM]: Fix ICMP tempsel Patrick McHardy
2005-02-19 12:23 ` YOSHIFUJI Hideaki / 吉藤英明
2005-02-19 18:43 ` Herbert Xu
2005-02-19 18:55 ` Patrick McHardy
2005-02-20 5:30 ` Patrick McHardy [this message]
2005-02-20 6:55 ` YOSHIFUJI Hideaki / 吉藤英明
2005-02-20 7:13 ` Patrick McHardy
2005-02-20 7:37 ` Herbert Xu
2005-02-20 8:35 ` Patrick McHardy
2005-02-20 8:58 ` YOSHIFUJI Hideaki
2005-02-20 11:12 ` Herbert Xu
2005-02-20 11:20 ` Patrick McHardy
2005-02-20 12:00 ` YOSHIFUJI Hideaki / 吉藤英明
2005-03-10 4:49 ` David S. Miller
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=42182082.9060301@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@oss.sgi.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.