@@ -59,9 +59,6 @@ static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp)
59
59
return 0 ;
60
60
}
61
61
62
- #if defined(CONFIG_IP_VS_PROTO_TCP ) || defined(CONFIG_IP_VS_PROTO_UDP ) || \
63
- defined(CONFIG_IP_VS_PROTO_SCTP ) || defined(CONFIG_IP_VS_PROTO_AH ) || \
64
- defined(CONFIG_IP_VS_PROTO_ESP )
65
62
/*
66
63
* register an ipvs protocols netns related data
67
64
*/
@@ -86,7 +83,6 @@ register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp)
86
83
87
84
return 0 ;
88
85
}
89
- #endif
90
86
91
87
/*
92
88
* unregister an ipvs protocol
@@ -316,22 +312,35 @@ ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp,
316
312
*/
317
313
int __net_init ip_vs_protocol_net_init (struct net * net )
318
314
{
315
+ int i , ret ;
316
+ static struct ip_vs_protocol * protos [] = {
319
317
#ifdef CONFIG_IP_VS_PROTO_TCP
320
- register_ip_vs_proto_netns ( net , & ip_vs_protocol_tcp );
318
+ & ip_vs_protocol_tcp ,
321
319
#endif
322
320
#ifdef CONFIG_IP_VS_PROTO_UDP
323
- register_ip_vs_proto_netns ( net , & ip_vs_protocol_udp );
321
+ & ip_vs_protocol_udp ,
324
322
#endif
325
323
#ifdef CONFIG_IP_VS_PROTO_SCTP
326
- register_ip_vs_proto_netns ( net , & ip_vs_protocol_sctp );
324
+ & ip_vs_protocol_sctp ,
327
325
#endif
328
326
#ifdef CONFIG_IP_VS_PROTO_AH
329
- register_ip_vs_proto_netns ( net , & ip_vs_protocol_ah );
327
+ & ip_vs_protocol_ah ,
330
328
#endif
331
329
#ifdef CONFIG_IP_VS_PROTO_ESP
332
- register_ip_vs_proto_netns ( net , & ip_vs_protocol_esp );
330
+ & ip_vs_protocol_esp ,
333
331
#endif
332
+ };
333
+
334
+ for (i = 0 ; i < ARRAY_SIZE (protos ); i ++ ) {
335
+ ret = register_ip_vs_proto_netns (net , protos [i ]);
336
+ if (ret < 0 )
337
+ goto cleanup ;
338
+ }
334
339
return 0 ;
340
+
341
+ cleanup :
342
+ ip_vs_protocol_net_cleanup (net );
343
+ return ret ;
335
344
}
336
345
337
346
void __net_exit ip_vs_protocol_net_cleanup (struct net * net )
0 commit comments