21 #define KMSG_COMPONENT "IPVS"
22 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
24 #include <linux/module.h>
25 #include <linux/kernel.h>
29 #include <linux/netfilter.h>
30 #include <linux/slab.h>
34 #include <linux/stat.h>
50 static inline int ip_vs_app_get(
struct ip_vs_app *app)
52 return try_module_get(app->
module);
56 static inline void ip_vs_app_put(
struct ip_vs_app *app)
82 INIT_LIST_HEAD(&inc->
p_list);
103 IP_VS_DBG(9,
"%s App %s:%u registered\n",
119 ip_vs_app_inc_release(
struct net *net,
struct ip_vs_app *inc)
129 IP_VS_DBG(9,
"%s App %s:%u unregistered\n",
148 if (
unlikely((result = ip_vs_app_get(inc->
app)) != 1))
159 ip_vs_app_put(inc->
app);
175 result = ip_vs_app_inc_new(net, app, proto, port);
214 return err ? ERR_PTR(err) :
a;
236 ip_vs_app_inc_release(net, inc);
294 IP_VS_DBG(9,
"%s(): added delta (%d) to seq\n",
295 __func__, vseq->
delta);
298 IP_VS_DBG(9,
"%s(): added previous_delta (%d) to seq\n",
324 "(%d) from ack_seq\n", __func__, vseq->
delta);
329 "previous_delta (%d) from ack_seq\n",
344 spin_lock(&cp->
lock);
351 spin_unlock(&cp->
lock);
358 const unsigned int tcp_offset = ip_hdrlen(skb);
365 th = (
struct tcphdr *)(skb_network_header(skb) + tcp_offset);
378 vs_fix_ack_seq(&cp->
in_seq, th);
386 if (!app->
pkt_out(app, cp, skb, &diff))
393 vs_seq_update(cp, &cp->
out_seq,
417 return app_tcp_pkt_out(cp, skb, app);
433 const unsigned int tcp_offset = ip_hdrlen(skb);
440 th = (
struct tcphdr *)(skb_network_header(skb) + tcp_offset);
451 vs_fix_seq(&cp->
in_seq, th);
453 vs_fix_ack_seq(&cp->
out_seq, th);
461 if (!app->
pkt_in(app, cp, skb, &diff))
468 vs_seq_update(cp, &cp->
in_seq,
492 return app_tcp_pkt_in(cp, skb, app);
504 #ifdef CONFIG_PROC_FS
523 static void *ip_vs_app_seq_start(
struct seq_file *seq, loff_t *pos)
525 struct net *net = seq_file_net(seq);
533 static void *ip_vs_app_seq_next(
struct seq_file *seq,
void *
v, loff_t *pos)
537 struct net *net = seq_file_net(seq);
542 return ip_vs_app_idx(ipvs, 0);
560 static void ip_vs_app_seq_stop(
struct seq_file *seq,
void *v)
565 static int ip_vs_app_seq_show(
struct seq_file *seq,
void *v)
568 seq_puts(seq,
"prot port usecnt name\n");
582 .
start = ip_vs_app_seq_start,
583 .next = ip_vs_app_seq_next,
584 .stop = ip_vs_app_seq_stop,
585 .show = ip_vs_app_seq_show,
596 .open = ip_vs_app_open,