1 This patch fixes bugs related to machine endianess (harmless on
2 little-endians, but causing that some of conntrack modules don't
3 work on big-endian machines) in netfilter/ip_nat code.
4 Bugs are similar to those fixed in
5 linux-2.4.20-netfilter-conntrack-endian.patch (which fixed
6 netfilter/ip_conntrack code).
8 The way that ip_conntrack_manip_proto unions (separately and in
9 ip_conntrack_tuple struct) were initialized was wrong - in compound
10 literals and initializers port number was "catched" by the first
11 union element, which is int32_t (so port was stored in 2 least
12 significant bytes, i.e. 2 bytes after beginning of tcp or udp
13 element on big-endian machines).
14 This fix uses C99 field specifiers.
16 Aternative way to fix can be zeroing whole structure and then
17 setting wanted fields in separate statements (like in some
18 other ip_nat_* or ip_conntrack_* modules).
21 Jakub Bogusz <qboosh@pld.org.pl>
23 --- linux-2.4.20/net/ipv4/netfilter/ip_nat_amanda.c.orig Tue May 20 11:18:23 2003
24 +++ linux-2.4.20/net/ipv4/netfilter/ip_nat_amanda.c Thu May 22 09:53:49 2003
26 mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
27 mr.range[0].min = mr.range[0].max
28 = ((union ip_conntrack_manip_proto)
30 + { .udp = { htons(port) } });
33 return ip_nat_setup_info(ct, &mr, hooknum);
34 --- linux-2.4.20/net/ipv4/netfilter/ip_nat_ftp.c.orig Fri Nov 29 00:53:15 2002
35 +++ linux-2.4.20/net/ipv4/netfilter/ip_nat_ftp.c Thu May 22 09:30:36 2003
37 mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
38 mr.range[0].min = mr.range[0].max
39 = ((union ip_conntrack_manip_proto)
40 - { htons(exp_ftp_info->port) });
41 + { .tcp = { htons(exp_ftp_info->port) } });
43 return ip_nat_setup_info(ct, &mr, hooknum);
45 --- linux-2.4.20/net/ipv4/netfilter/ip_nat_h323.c.orig Thu May 22 10:46:47 2003
46 +++ linux-2.4.20/net/ipv4/netfilter/ip_nat_h323.c Thu May 22 10:01:11 2003
48 mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
49 mr.range[0].min = mr.range[0].max
50 = ((union ip_conntrack_manip_proto)
52 + { .tcp = { port } });
55 ret = ip_nat_setup_info(ct, &mr, hooknum);
58 IP_NAT_HELPER_F_ALWAYS, /* flags */
59 THIS_MODULE, /* module */
60 - { { 0, { __constant_htons(H225_PORT) } }, /* tuple */
61 + { { 0, { .tcp = { __constant_htons(H225_PORT) } } }, /* tuple */
62 { 0, { 0 }, IPPROTO_TCP } },
63 - { { 0, { 0xFFFF } }, /* mask */
64 + { { 0, { .tcp = { 0xFFFF } } }, /* mask */
65 { 0, { 0 }, 0xFFFF } },
66 h225_nat_help, /* helper */
67 h225_nat_expected /* expectfn */
68 --- linux-2.4.20/net/ipv4/netfilter/ip_nat_snmp_basic.c.orig Fri Nov 29 00:53:15 2002
69 +++ linux-2.4.20/net/ipv4/netfilter/ip_nat_snmp_basic.c Thu May 22 10:27:06 2003
72 IP_NAT_HELPER_F_STANDALONE,
74 - { { 0, { __constant_htons(SNMP_PORT) } },
75 + { { 0, { .udp = { __constant_htons(SNMP_PORT) } } },
76 { 0, { 0 }, IPPROTO_UDP } },
77 - { { 0, { 0xFFFF } },
78 + { { 0, { .udp = { 0xFFFF } } },
79 { 0, { 0 }, 0xFFFF } },
84 IP_NAT_HELPER_F_STANDALONE,
86 - { { 0, { __constant_htons(SNMP_TRAP_PORT) } },
87 + { { 0, { .udp = { __constant_htons(SNMP_TRAP_PORT) } } },
88 { 0, { 0 }, IPPROTO_UDP } },
89 - { { 0, { 0xFFFF } },
90 + { { 0, { .udp = { 0xFFFF } } },
91 { 0, { 0 }, 0xFFFF } },
94 --- linux-2.4.20/net/ipv4/netfilter/ip_nat_talk.c.orig Tue May 20 11:18:24 2003
95 +++ linux-2.4.20/net/ipv4/netfilter/ip_nat_talk.c Thu May 22 10:36:17 2003
98 IP_NAT_HELPER_F_ALWAYS, /* flags */
99 THIS_MODULE, /* module */
100 - { { 0, { __constant_htons(TALK_PORT) } }, /* tuple */
101 + { { 0, { .udp = { __constant_htons(TALK_PORT) } } }, /* tuple */
102 { 0, { 0 }, IPPROTO_UDP } },
103 - { { 0, { 0xFFFF } }, /* mask */
104 + { { 0, { .udp = { 0xFFFF } } }, /* mask */
105 { 0, { 0 }, 0xFFFF } },
107 talk_nat_expected }, /* expectfn */
110 IP_NAT_HELPER_F_ALWAYS, /* flags */
111 THIS_MODULE, /* module */
112 - { { 0, { __constant_htons(NTALK_PORT) } }, /* tuple */
113 + { { 0, { .udp = { __constant_htons(NTALK_PORT) } } }, /* tuple */
114 { 0, { 0 }, IPPROTO_UDP } },
115 - { { 0, { 0xFFFF } }, /* mask */
116 + { { 0, { .udp = { 0xFFFF } } }, /* mask */
117 { 0, { 0 }, 0xFFFF } },
119 talk_nat_expected } /* expectfn */
121 mr.range[0].flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
122 mr.range[0].min = mr.range[0].max
123 = ((union ip_conntrack_manip_proto)
125 + { .udp = { port } });
127 ret = ip_nat_setup_info(ct, &mr, hooknum);