diff options
-rw-r--r-- | include/net/ip_vs.h | 16 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_conn.c | 19 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_ctl.c | 4 | ||||
-rw-r--r-- | net/netfilter/ipvs/ip_vs_pe.c | 14 |
4 files changed, 30 insertions, 23 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index b7bbd6c28cfa..be2b5690f892 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -422,6 +422,7 @@ struct ip_vs_conn { | |||
422 | struct ip_vs_seq in_seq; /* incoming seq. struct */ | 422 | struct ip_vs_seq in_seq; /* incoming seq. struct */ |
423 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ | 423 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ |
424 | 424 | ||
425 | const struct ip_vs_pe *pe; | ||
425 | char *pe_data; | 426 | char *pe_data; |
426 | __u8 pe_data_len; | 427 | __u8 pe_data_len; |
427 | }; | 428 | }; |
@@ -814,8 +815,19 @@ void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe); | |||
814 | void ip_vs_unbind_pe(struct ip_vs_service *svc); | 815 | void ip_vs_unbind_pe(struct ip_vs_service *svc); |
815 | int register_ip_vs_pe(struct ip_vs_pe *pe); | 816 | int register_ip_vs_pe(struct ip_vs_pe *pe); |
816 | int unregister_ip_vs_pe(struct ip_vs_pe *pe); | 817 | int unregister_ip_vs_pe(struct ip_vs_pe *pe); |
817 | extern struct ip_vs_pe *ip_vs_pe_get(const char *name); | 818 | struct ip_vs_pe *ip_vs_pe_getbyname(const char *name); |
818 | extern void ip_vs_pe_put(struct ip_vs_pe *pe); | 819 | |
820 | static inline void ip_vs_pe_get(const struct ip_vs_pe *pe) | ||
821 | { | ||
822 | if (pe && pe->module) | ||
823 | __module_get(pe->module); | ||
824 | } | ||
825 | |||
826 | static inline void ip_vs_pe_put(const struct ip_vs_pe *pe) | ||
827 | { | ||
828 | if (pe && pe->module) | ||
829 | module_put(pe->module); | ||
830 | } | ||
819 | 831 | ||
820 | /* | 832 | /* |
821 | * IPVS protocol functions (from ip_vs_proto.c) | 833 | * IPVS protocol functions (from ip_vs_proto.c) |
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index e9adecdc8ca4..64a9ca314100 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
@@ -176,8 +176,8 @@ static unsigned int ip_vs_conn_hashkey_conn(const struct ip_vs_conn *cp) | |||
176 | ip_vs_conn_fill_param(cp->af, cp->protocol, &cp->caddr, cp->cport, | 176 | ip_vs_conn_fill_param(cp->af, cp->protocol, &cp->caddr, cp->cport, |
177 | NULL, 0, &p); | 177 | NULL, 0, &p); |
178 | 178 | ||
179 | if (cp->dest && cp->dest->svc->pe) { | 179 | if (cp->pe) { |
180 | p.pe = cp->dest->svc->pe; | 180 | p.pe = cp->pe; |
181 | p.pe_data = cp->pe_data; | 181 | p.pe_data = cp->pe_data; |
182 | p.pe_data_len = cp->pe_data_len; | 182 | p.pe_data_len = cp->pe_data_len; |
183 | } | 183 | } |
@@ -765,6 +765,7 @@ static void ip_vs_conn_expire(unsigned long data) | |||
765 | if (cp->flags & IP_VS_CONN_F_NFCT) | 765 | if (cp->flags & IP_VS_CONN_F_NFCT) |
766 | ip_vs_conn_drop_conntrack(cp); | 766 | ip_vs_conn_drop_conntrack(cp); |
767 | 767 | ||
768 | ip_vs_pe_put(cp->pe); | ||
768 | kfree(cp->pe_data); | 769 | kfree(cp->pe_data); |
769 | if (unlikely(cp->app != NULL)) | 770 | if (unlikely(cp->app != NULL)) |
770 | ip_vs_unbind_app(cp); | 771 | ip_vs_unbind_app(cp); |
@@ -826,7 +827,9 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p, | |||
826 | &cp->daddr, daddr); | 827 | &cp->daddr, daddr); |
827 | cp->dport = dport; | 828 | cp->dport = dport; |
828 | cp->flags = flags; | 829 | cp->flags = flags; |
829 | if (flags & IP_VS_CONN_F_TEMPLATE && p->pe_data) { | 830 | if (flags & IP_VS_CONN_F_TEMPLATE && p->pe) { |
831 | ip_vs_pe_get(p->pe); | ||
832 | cp->pe = p->pe; | ||
830 | cp->pe_data = p->pe_data; | 833 | cp->pe_data = p->pe_data; |
831 | cp->pe_data_len = p->pe_data_len; | 834 | cp->pe_data_len = p->pe_data_len; |
832 | } | 835 | } |
@@ -958,15 +961,13 @@ static int ip_vs_conn_seq_show(struct seq_file *seq, void *v) | |||
958 | char pe_data[IP_VS_PENAME_MAXLEN + IP_VS_PEDATA_MAXLEN + 3]; | 961 | char pe_data[IP_VS_PENAME_MAXLEN + IP_VS_PEDATA_MAXLEN + 3]; |
959 | size_t len = 0; | 962 | size_t len = 0; |
960 | 963 | ||
961 | if (cp->dest && cp->pe_data && | 964 | if (cp->pe_data) { |
962 | cp->dest->svc->pe->show_pe_data) { | ||
963 | pe_data[0] = ' '; | 965 | pe_data[0] = ' '; |
964 | len = strlen(cp->dest->svc->pe->name); | 966 | len = strlen(cp->pe->name); |
965 | memcpy(pe_data + 1, cp->dest->svc->pe->name, len); | 967 | memcpy(pe_data + 1, cp->pe->name, len); |
966 | pe_data[len + 1] = ' '; | 968 | pe_data[len + 1] = ' '; |
967 | len += 2; | 969 | len += 2; |
968 | len += cp->dest->svc->pe->show_pe_data(cp, | 970 | len += cp->pe->show_pe_data(cp, pe_data + len); |
969 | pe_data + len); | ||
970 | } | 971 | } |
971 | pe_data[len] = '\0'; | 972 | pe_data[len] = '\0'; |
972 | 973 | ||
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c index 5f5daa30b0af..3e92558dfcc2 100644 --- a/net/netfilter/ipvs/ip_vs_ctl.c +++ b/net/netfilter/ipvs/ip_vs_ctl.c | |||
@@ -1139,7 +1139,7 @@ ip_vs_add_service(struct ip_vs_service_user_kern *u, | |||
1139 | } | 1139 | } |
1140 | 1140 | ||
1141 | if (u->pe_name && *u->pe_name) { | 1141 | if (u->pe_name && *u->pe_name) { |
1142 | pe = ip_vs_pe_get(u->pe_name); | 1142 | pe = ip_vs_pe_getbyname(u->pe_name); |
1143 | if (pe == NULL) { | 1143 | if (pe == NULL) { |
1144 | pr_info("persistence engine module ip_vs_pe_%s " | 1144 | pr_info("persistence engine module ip_vs_pe_%s " |
1145 | "not found\n", u->pe_name); | 1145 | "not found\n", u->pe_name); |
@@ -1250,7 +1250,7 @@ ip_vs_edit_service(struct ip_vs_service *svc, struct ip_vs_service_user_kern *u) | |||
1250 | old_sched = sched; | 1250 | old_sched = sched; |
1251 | 1251 | ||
1252 | if (u->pe_name && *u->pe_name) { | 1252 | if (u->pe_name && *u->pe_name) { |
1253 | pe = ip_vs_pe_get(u->pe_name); | 1253 | pe = ip_vs_pe_getbyname(u->pe_name); |
1254 | if (pe == NULL) { | 1254 | if (pe == NULL) { |
1255 | pr_info("persistence engine module ip_vs_pe_%s " | 1255 | pr_info("persistence engine module ip_vs_pe_%s " |
1256 | "not found\n", u->pe_name); | 1256 | "not found\n", u->pe_name); |
diff --git a/net/netfilter/ipvs/ip_vs_pe.c b/net/netfilter/ipvs/ip_vs_pe.c index 3414af70ee12..e99f920b93d1 100644 --- a/net/netfilter/ipvs/ip_vs_pe.c +++ b/net/netfilter/ipvs/ip_vs_pe.c | |||
@@ -30,7 +30,7 @@ void ip_vs_unbind_pe(struct ip_vs_service *svc) | |||
30 | 30 | ||
31 | /* Get pe in the pe list by name */ | 31 | /* Get pe in the pe list by name */ |
32 | static struct ip_vs_pe * | 32 | static struct ip_vs_pe * |
33 | ip_vs_pe_getbyname(const char *pe_name) | 33 | __ip_vs_pe_getbyname(const char *pe_name) |
34 | { | 34 | { |
35 | struct ip_vs_pe *pe; | 35 | struct ip_vs_pe *pe; |
36 | 36 | ||
@@ -60,28 +60,22 @@ ip_vs_pe_getbyname(const char *pe_name) | |||
60 | } | 60 | } |
61 | 61 | ||
62 | /* Lookup pe and try to load it if it doesn't exist */ | 62 | /* Lookup pe and try to load it if it doesn't exist */ |
63 | struct ip_vs_pe *ip_vs_pe_get(const char *name) | 63 | struct ip_vs_pe *ip_vs_pe_getbyname(const char *name) |
64 | { | 64 | { |
65 | struct ip_vs_pe *pe; | 65 | struct ip_vs_pe *pe; |
66 | 66 | ||
67 | /* Search for the pe by name */ | 67 | /* Search for the pe by name */ |
68 | pe = ip_vs_pe_getbyname(name); | 68 | pe = __ip_vs_pe_getbyname(name); |
69 | 69 | ||
70 | /* If pe not found, load the module and search again */ | 70 | /* If pe not found, load the module and search again */ |
71 | if (!pe) { | 71 | if (!pe) { |
72 | request_module("ip_vs_pe_%s", name); | 72 | request_module("ip_vs_pe_%s", name); |
73 | pe = ip_vs_pe_getbyname(name); | 73 | pe = __ip_vs_pe_getbyname(name); |
74 | } | 74 | } |
75 | 75 | ||
76 | return pe; | 76 | return pe; |
77 | } | 77 | } |
78 | 78 | ||
79 | void ip_vs_pe_put(struct ip_vs_pe *pe) | ||
80 | { | ||
81 | if (pe && pe->module) | ||
82 | module_put(pe->module); | ||
83 | } | ||
84 | |||
85 | /* Register a pe in the pe list */ | 79 | /* Register a pe in the pe list */ |
86 | int register_ip_vs_pe(struct ip_vs_pe *pe) | 80 | int register_ip_vs_pe(struct ip_vs_pe *pe) |
87 | { | 81 | { |