2 * ip_vs_proto_ah_esp.c: AH/ESP IPSec load balancing support for IPVS
4 * Authors: Julian Anastasov <ja@ssi.bg>, February 2002
5 * Wensong Zhang <wensong@linuxvirtualserver.org>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation;
15 #include <linux/module.h>
16 #include <linux/kernel.h>
17 #include <linux/netfilter.h>
18 #include <linux/netfilter_ipv4.h>
20 #include <net/ip_vs.h>
38 #define PORT_ISAKMP 500
41 static struct ip_vs_conn
*
42 ah_esp_conn_in_get(const struct sk_buff
*skb
,
43 struct ip_vs_protocol
*pp
,
44 const struct iphdr
*iph
,
45 unsigned int proto_off
,
48 struct ip_vs_conn
*cp
;
50 if (likely(!inverse
)) {
51 cp
= ip_vs_conn_in_get(IPPROTO_UDP
,
57 cp
= ip_vs_conn_in_get(IPPROTO_UDP
,
66 * We are not sure if the packet is from our
67 * service, so our conn_schedule hook should return NF_ACCEPT
69 IP_VS_DBG(12, "Unknown ISAKMP entry for outin packet "
70 "%s%s %u.%u.%u.%u->%u.%u.%u.%u\n",
71 inverse
? "ICMP+" : "",
81 static struct ip_vs_conn
*
82 ah_esp_conn_out_get(const struct sk_buff
*skb
, struct ip_vs_protocol
*pp
,
83 const struct iphdr
*iph
, unsigned int proto_off
, int inverse
)
85 struct ip_vs_conn
*cp
;
87 if (likely(!inverse
)) {
88 cp
= ip_vs_conn_out_get(IPPROTO_UDP
,
94 cp
= ip_vs_conn_out_get(IPPROTO_UDP
,
102 IP_VS_DBG(12, "Unknown ISAKMP entry for inout packet "
103 "%s%s %u.%u.%u.%u->%u.%u.%u.%u\n",
104 inverse
? "ICMP+" : "",
107 NIPQUAD(iph
->daddr
));
115 ah_esp_conn_schedule(struct sk_buff
*skb
,
116 struct ip_vs_protocol
*pp
,
117 int *verdict
, struct ip_vs_conn
**cpp
)
120 * AH/ESP is only related traffic. Pass the packet to IP stack.
122 *verdict
= NF_ACCEPT
;
128 ah_esp_debug_packet(struct ip_vs_protocol
*pp
, const struct sk_buff
*skb
,
129 int offset
, const char *msg
)
132 struct iphdr _iph
, *ih
;
134 ih
= skb_header_pointer(skb
, offset
, sizeof(_iph
), &_iph
);
136 sprintf(buf
, "%s TRUNCATED", pp
->name
);
138 sprintf(buf
, "%s %u.%u.%u.%u->%u.%u.%u.%u",
139 pp
->name
, NIPQUAD(ih
->saddr
),
142 printk(KERN_DEBUG
"IPVS: %s: %s\n", msg
, buf
);
146 static void ah_esp_init(struct ip_vs_protocol
*pp
)
148 /* nothing to do now */
152 static void ah_esp_exit(struct ip_vs_protocol
*pp
)
154 /* nothing to do now */
158 #ifdef CONFIG_IP_VS_PROTO_AH
159 struct ip_vs_protocol ip_vs_protocol_ah
= {
161 .protocol
= IPPROTO_AH
,
166 .conn_schedule
= ah_esp_conn_schedule
,
167 .conn_in_get
= ah_esp_conn_in_get
,
168 .conn_out_get
= ah_esp_conn_out_get
,
169 .snat_handler
= NULL
,
170 .dnat_handler
= NULL
,
172 .state_transition
= NULL
,
173 .register_app
= NULL
,
174 .unregister_app
= NULL
,
175 .app_conn_bind
= NULL
,
176 .debug_packet
= ah_esp_debug_packet
,
177 .timeout_change
= NULL
, /* ISAKMP */
178 .set_state_timeout
= NULL
,
182 #ifdef CONFIG_IP_VS_PROTO_ESP
183 struct ip_vs_protocol ip_vs_protocol_esp
= {
185 .protocol
= IPPROTO_ESP
,
190 .conn_schedule
= ah_esp_conn_schedule
,
191 .conn_in_get
= ah_esp_conn_in_get
,
192 .conn_out_get
= ah_esp_conn_out_get
,
193 .snat_handler
= NULL
,
194 .dnat_handler
= NULL
,
196 .state_transition
= NULL
,
197 .register_app
= NULL
,
198 .unregister_app
= NULL
,
199 .app_conn_bind
= NULL
,
200 .debug_packet
= ah_esp_debug_packet
,
201 .timeout_change
= NULL
, /* ISAKMP */