@@ -34,19 +34,17 @@ static int nf_flow_state_check(struct flow_offload *flow, int proto,
34
34
return 0 ;
35
35
}
36
36
37
- static int nf_flow_nat_ip_tcp (struct sk_buff * skb , unsigned int thoff ,
38
- __be32 addr , __be32 new_addr )
37
+ static void nf_flow_nat_ip_tcp (struct sk_buff * skb , unsigned int thoff ,
38
+ __be32 addr , __be32 new_addr )
39
39
{
40
40
struct tcphdr * tcph ;
41
41
42
42
tcph = (void * )(skb_network_header (skb ) + thoff );
43
43
inet_proto_csum_replace4 (& tcph -> check , skb , addr , new_addr , true);
44
-
45
- return 0 ;
46
44
}
47
45
48
- static int nf_flow_nat_ip_udp (struct sk_buff * skb , unsigned int thoff ,
49
- __be32 addr , __be32 new_addr )
46
+ static void nf_flow_nat_ip_udp (struct sk_buff * skb , unsigned int thoff ,
47
+ __be32 addr , __be32 new_addr )
50
48
{
51
49
struct udphdr * udph ;
52
50
@@ -57,31 +55,25 @@ static int nf_flow_nat_ip_udp(struct sk_buff *skb, unsigned int thoff,
57
55
if (!udph -> check )
58
56
udph -> check = CSUM_MANGLED_0 ;
59
57
}
60
-
61
- return 0 ;
62
58
}
63
59
64
- static int nf_flow_nat_ip_l4proto (struct sk_buff * skb , struct iphdr * iph ,
65
- unsigned int thoff , __be32 addr ,
66
- __be32 new_addr )
60
+ static void nf_flow_nat_ip_l4proto (struct sk_buff * skb , struct iphdr * iph ,
61
+ unsigned int thoff , __be32 addr ,
62
+ __be32 new_addr )
67
63
{
68
64
switch (iph -> protocol ) {
69
65
case IPPROTO_TCP :
70
- if (nf_flow_nat_ip_tcp (skb , thoff , addr , new_addr ) < 0 )
71
- return NF_DROP ;
66
+ nf_flow_nat_ip_tcp (skb , thoff , addr , new_addr );
72
67
break ;
73
68
case IPPROTO_UDP :
74
- if (nf_flow_nat_ip_udp (skb , thoff , addr , new_addr ) < 0 )
75
- return NF_DROP ;
69
+ nf_flow_nat_ip_udp (skb , thoff , addr , new_addr );
76
70
break ;
77
71
}
78
-
79
- return 0 ;
80
72
}
81
73
82
- static int nf_flow_snat_ip (const struct flow_offload * flow , struct sk_buff * skb ,
83
- struct iphdr * iph , unsigned int thoff ,
84
- enum flow_offload_tuple_dir dir )
74
+ static void nf_flow_snat_ip (const struct flow_offload * flow ,
75
+ struct sk_buff * skb , struct iphdr * iph ,
76
+ unsigned int thoff , enum flow_offload_tuple_dir dir )
85
77
{
86
78
__be32 addr , new_addr ;
87
79
@@ -99,12 +91,12 @@ static int nf_flow_snat_ip(const struct flow_offload *flow, struct sk_buff *skb,
99
91
}
100
92
csum_replace4 (& iph -> check , addr , new_addr );
101
93
102
- return nf_flow_nat_ip_l4proto (skb , iph , thoff , addr , new_addr );
94
+ nf_flow_nat_ip_l4proto (skb , iph , thoff , addr , new_addr );
103
95
}
104
96
105
- static int nf_flow_dnat_ip (const struct flow_offload * flow , struct sk_buff * skb ,
106
- struct iphdr * iph , unsigned int thoff ,
107
- enum flow_offload_tuple_dir dir )
97
+ static void nf_flow_dnat_ip (const struct flow_offload * flow ,
98
+ struct sk_buff * skb , struct iphdr * iph ,
99
+ unsigned int thoff , enum flow_offload_tuple_dir dir )
108
100
{
109
101
__be32 addr , new_addr ;
110
102
@@ -122,24 +114,21 @@ static int nf_flow_dnat_ip(const struct flow_offload *flow, struct sk_buff *skb,
122
114
}
123
115
csum_replace4 (& iph -> check , addr , new_addr );
124
116
125
- return nf_flow_nat_ip_l4proto (skb , iph , thoff , addr , new_addr );
117
+ nf_flow_nat_ip_l4proto (skb , iph , thoff , addr , new_addr );
126
118
}
127
119
128
- static int nf_flow_nat_ip (const struct flow_offload * flow , struct sk_buff * skb ,
120
+ static void nf_flow_nat_ip (const struct flow_offload * flow , struct sk_buff * skb ,
129
121
unsigned int thoff , enum flow_offload_tuple_dir dir ,
130
122
struct iphdr * iph )
131
123
{
132
- if (test_bit (NF_FLOW_SNAT , & flow -> flags ) &&
133
- (nf_flow_snat_port (flow , skb , thoff , iph -> protocol , dir ) < 0 ||
134
- nf_flow_snat_ip (flow , skb , iph , thoff , dir ) < 0 ))
135
- return -1 ;
136
-
137
- if (test_bit (NF_FLOW_DNAT , & flow -> flags ) &&
138
- (nf_flow_dnat_port (flow , skb , thoff , iph -> protocol , dir ) < 0 ||
139
- nf_flow_dnat_ip (flow , skb , iph , thoff , dir ) < 0 ))
140
- return -1 ;
141
-
142
- return 0 ;
124
+ if (test_bit (NF_FLOW_SNAT , & flow -> flags )) {
125
+ nf_flow_snat_port (flow , skb , thoff , iph -> protocol , dir );
126
+ nf_flow_snat_ip (flow , skb , iph , thoff , dir );
127
+ }
128
+ if (test_bit (NF_FLOW_DNAT , & flow -> flags )) {
129
+ nf_flow_dnat_port (flow , skb , thoff , iph -> protocol , dir );
130
+ nf_flow_dnat_ip (flow , skb , iph , thoff , dir );
131
+ }
143
132
}
144
133
145
134
static bool ip_has_options (unsigned int thoff )
@@ -276,8 +265,7 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
276
265
return NF_DROP ;
277
266
278
267
iph = ip_hdr (skb );
279
- if (nf_flow_nat_ip (flow , skb , thoff , dir , iph ) < 0 )
280
- return NF_DROP ;
268
+ nf_flow_nat_ip (flow , skb , thoff , dir , iph );
281
269
282
270
ip_decrease_ttl (iph );
283
271
skb -> tstamp = 0 ;
@@ -301,22 +289,21 @@ nf_flow_offload_ip_hook(void *priv, struct sk_buff *skb,
301
289
}
302
290
EXPORT_SYMBOL_GPL (nf_flow_offload_ip_hook );
303
291
304
- static int nf_flow_nat_ipv6_tcp (struct sk_buff * skb , unsigned int thoff ,
305
- struct in6_addr * addr ,
306
- struct in6_addr * new_addr )
292
+ static void nf_flow_nat_ipv6_tcp (struct sk_buff * skb , unsigned int thoff ,
293
+ struct in6_addr * addr ,
294
+ struct in6_addr * new_addr ,
295
+ struct ipv6hdr * ip6h )
307
296
{
308
297
struct tcphdr * tcph ;
309
298
310
299
tcph = (void * )(skb_network_header (skb ) + thoff );
311
300
inet_proto_csum_replace16 (& tcph -> check , skb , addr -> s6_addr32 ,
312
301
new_addr -> s6_addr32 , true);
313
-
314
- return 0 ;
315
302
}
316
303
317
- static int nf_flow_nat_ipv6_udp (struct sk_buff * skb , unsigned int thoff ,
318
- struct in6_addr * addr ,
319
- struct in6_addr * new_addr )
304
+ static void nf_flow_nat_ipv6_udp (struct sk_buff * skb , unsigned int thoff ,
305
+ struct in6_addr * addr ,
306
+ struct in6_addr * new_addr )
320
307
{
321
308
struct udphdr * udph ;
322
309
@@ -327,32 +314,26 @@ static int nf_flow_nat_ipv6_udp(struct sk_buff *skb, unsigned int thoff,
327
314
if (!udph -> check )
328
315
udph -> check = CSUM_MANGLED_0 ;
329
316
}
330
-
331
- return 0 ;
332
317
}
333
318
334
- static int nf_flow_nat_ipv6_l4proto (struct sk_buff * skb , struct ipv6hdr * ip6h ,
335
- unsigned int thoff , struct in6_addr * addr ,
336
- struct in6_addr * new_addr )
319
+ static void nf_flow_nat_ipv6_l4proto (struct sk_buff * skb , struct ipv6hdr * ip6h ,
320
+ unsigned int thoff , struct in6_addr * addr ,
321
+ struct in6_addr * new_addr )
337
322
{
338
323
switch (ip6h -> nexthdr ) {
339
324
case IPPROTO_TCP :
340
- if (nf_flow_nat_ipv6_tcp (skb , thoff , addr , new_addr ) < 0 )
341
- return NF_DROP ;
325
+ nf_flow_nat_ipv6_tcp (skb , thoff , addr , new_addr , ip6h );
342
326
break ;
343
327
case IPPROTO_UDP :
344
- if (nf_flow_nat_ipv6_udp (skb , thoff , addr , new_addr ) < 0 )
345
- return NF_DROP ;
328
+ nf_flow_nat_ipv6_udp (skb , thoff , addr , new_addr );
346
329
break ;
347
330
}
348
-
349
- return 0 ;
350
331
}
351
332
352
- static int nf_flow_snat_ipv6 (const struct flow_offload * flow ,
353
- struct sk_buff * skb , struct ipv6hdr * ip6h ,
354
- unsigned int thoff ,
355
- enum flow_offload_tuple_dir dir )
333
+ static void nf_flow_snat_ipv6 (const struct flow_offload * flow ,
334
+ struct sk_buff * skb , struct ipv6hdr * ip6h ,
335
+ unsigned int thoff ,
336
+ enum flow_offload_tuple_dir dir )
356
337
{
357
338
struct in6_addr addr , new_addr ;
358
339
@@ -369,13 +350,13 @@ static int nf_flow_snat_ipv6(const struct flow_offload *flow,
369
350
break ;
370
351
}
371
352
372
- return nf_flow_nat_ipv6_l4proto (skb , ip6h , thoff , & addr , & new_addr );
353
+ nf_flow_nat_ipv6_l4proto (skb , ip6h , thoff , & addr , & new_addr );
373
354
}
374
355
375
- static int nf_flow_dnat_ipv6 (const struct flow_offload * flow ,
376
- struct sk_buff * skb , struct ipv6hdr * ip6h ,
377
- unsigned int thoff ,
378
- enum flow_offload_tuple_dir dir )
356
+ static void nf_flow_dnat_ipv6 (const struct flow_offload * flow ,
357
+ struct sk_buff * skb , struct ipv6hdr * ip6h ,
358
+ unsigned int thoff ,
359
+ enum flow_offload_tuple_dir dir )
379
360
{
380
361
struct in6_addr addr , new_addr ;
381
362
@@ -392,27 +373,24 @@ static int nf_flow_dnat_ipv6(const struct flow_offload *flow,
392
373
break ;
393
374
}
394
375
395
- return nf_flow_nat_ipv6_l4proto (skb , ip6h , thoff , & addr , & new_addr );
376
+ nf_flow_nat_ipv6_l4proto (skb , ip6h , thoff , & addr , & new_addr );
396
377
}
397
378
398
- static int nf_flow_nat_ipv6 (const struct flow_offload * flow ,
399
- struct sk_buff * skb ,
400
- enum flow_offload_tuple_dir dir ,
401
- struct ipv6hdr * ip6h )
379
+ static void nf_flow_nat_ipv6 (const struct flow_offload * flow ,
380
+ struct sk_buff * skb ,
381
+ enum flow_offload_tuple_dir dir ,
382
+ struct ipv6hdr * ip6h )
402
383
{
403
384
unsigned int thoff = sizeof (* ip6h );
404
385
405
- if (test_bit (NF_FLOW_SNAT , & flow -> flags ) &&
406
- (nf_flow_snat_port (flow , skb , thoff , ip6h -> nexthdr , dir ) < 0 ||
407
- nf_flow_snat_ipv6 (flow , skb , ip6h , thoff , dir ) < 0 ))
408
- return -1 ;
409
-
410
- if (test_bit (NF_FLOW_DNAT , & flow -> flags ) &&
411
- (nf_flow_dnat_port (flow , skb , thoff , ip6h -> nexthdr , dir ) < 0 ||
412
- nf_flow_dnat_ipv6 (flow , skb , ip6h , thoff , dir ) < 0 ))
413
- return -1 ;
414
-
415
- return 0 ;
386
+ if (test_bit (NF_FLOW_SNAT , & flow -> flags )) {
387
+ nf_flow_snat_port (flow , skb , thoff , ip6h -> nexthdr , dir );
388
+ nf_flow_snat_ipv6 (flow , skb , ip6h , thoff , dir );
389
+ }
390
+ if (test_bit (NF_FLOW_DNAT , & flow -> flags )) {
391
+ nf_flow_dnat_port (flow , skb , thoff , ip6h -> nexthdr , dir );
392
+ nf_flow_dnat_ipv6 (flow , skb , ip6h , thoff , dir );
393
+ }
416
394
}
417
395
418
396
static int nf_flow_tuple_ipv6 (struct sk_buff * skb , const struct net_device * dev ,
@@ -507,8 +485,7 @@ nf_flow_offload_ipv6_hook(void *priv, struct sk_buff *skb,
507
485
return NF_DROP ;
508
486
509
487
ip6h = ipv6_hdr (skb );
510
- if (nf_flow_nat_ipv6 (flow , skb , dir , ip6h ) < 0 )
511
- return NF_DROP ;
488
+ nf_flow_nat_ipv6 (flow , skb , dir , ip6h );
512
489
513
490
ip6h -> hop_limit -- ;
514
491
skb -> tstamp = 0 ;
0 commit comments