
laforge at netfilter
Nov 24, 2005, 12:07 PM
Post #8 of 33
(1233 views)
Permalink
|
|
Re: [PATCH] CTA_PROTO_NUM is u_int8_t not u_int16_t (was Re: CTA_PROTO_NUM u_int8_t or u_int16_t)
[In reply to]
|
|
On Wed, Nov 23, 2005 at 11:31:18AM +0100, Krzysztof Oledzki wrote: > > > On Wed, 23 Nov 2005, Patrick McHardy wrote: > > >Pablo Neira wrote: > >>Harald Welte wrote: > >>>another alternative was to introduce a new CTA_PROTO_NUM8 value, which > >>>is more explicit (but somehow stupid). > >>Why don't we send a patch to -stable? I think that most people will use > >>lastest stable branch in 2.6.14, so only < 2.6.14.3 would be broken. I > >>still don't like too much the idea of adding a new field just because of > >>this bugfix :( > >I would be fine with this. > > Can we make it before 2.6.14.3? I don't know how long we are going to wait for 2.6.14.4. what about the following fix? If no objections arise, I'll submit it tomorrow. diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h @@ -58,12 +58,13 @@ enum ctattr_ip { enum ctattr_l4proto { CTA_PROTO_UNSPEC, - CTA_PROTO_NUM, + CTA_PROTO_NUM, /* old 16bit CTA_PROTO, pre-2.6.15 */ CTA_PROTO_SRC_PORT, CTA_PROTO_DST_PORT, CTA_PROTO_ICMP_ID, CTA_PROTO_ICMP_TYPE, CTA_PROTO_ICMP_CODE, + CTA_PROTO, /* new CTA_PROTO value, 8bit width */ __CTA_PROTO_MAX }; #define CTA_PROTO_MAX (__CTA_PROTO_MAX - 1) diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c @@ -57,7 +57,7 @@ ctnetlink_dump_tuples_proto(struct sk_bu struct ip_conntrack_protocol *proto; int ret = 0; - NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum); + NFA_PUT(skb, CTA_PROTO, sizeof(u_int8_t), &tuple->dst.protonum); /* If no protocol helper is found, this function will return the * generic protocol helper, so proto won't *ever* be NULL */ @@ -508,6 +508,7 @@ static const size_t cta_min_proto[CTA_PR [CTA_PROTO_ICMP_TYPE-1] = sizeof(u_int8_t), [CTA_PROTO_ICMP_CODE-1] = sizeof(u_int8_t), [CTA_PROTO_ICMP_ID-1] = sizeof(u_int16_t), + [CTA_PROTO-1] = sizeof(u_int8_t), }; static inline int @@ -525,9 +526,14 @@ ctnetlink_parse_tuple_proto(struct nfatt if (nfattr_bad_size(tb, CTA_PROTO_MAX, cta_min_proto)) return -EINVAL; - if (!tb[CTA_PROTO_NUM-1]) + /* CTA_PROTO_NUM has to be kept for backwards compatibility */ + if (tb[CTA_PROTO-1]) + tuple->dst.protonum = *(u_int8_t *)NFA_DATA(tb[CTA_PROTO-1]); + else if (tb[CTA_PROTO_NUM-1]) + tuple->dst.protonum = + *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]); + else return -EINVAL; - tuple->dst.protonum = *(u_int16_t *)NFA_DATA(tb[CTA_PROTO_NUM-1]); proto = ip_conntrack_proto_find_get(tuple->dst.protonum); -- - Harald Welte <laforge [at] netfilter> http://netfilter.org/ ============================================================================ "Fragmentation is like classful addressing -- an interesting early architectural error that shows how much experimentation was going on while IP was being designed." -- Paul Vixie
|