IPVS: Prepare for transferring firewall marks (fwmark) to the backup daemon.
Subsystems (4)
RFC PATCH 1/4 IPVS: Prepare for transferring firewall marks (fwmark) to the backup daemon.
Two structs will have fwmark added:
* ip_vs_conn
* ip_vs_conn_param
ip_vs_conn_fill_param will have an extra param - fwmark The effects of that is in this patch.
--- include/net/ip_vs.h | 7 ++++++- net/netfilter/ipvs/ip_vs_conn.c | 9 +++++---- net/netfilter/ipvs/ip_vs_core.c | 13 +++++++------ net/netfilter/ipvs/ip_vs_ctl.c | 4 ++-- net/netfilter/ipvs/ip_vs_ftp.c | 8 +++++--- net/netfilter/ipvs/ip_vs_nfct.c | 2 +- net/netfilter/ipvs/ip_vs_proto_ah_esp.c | 13 ++++++++----- net/netfilter/ipvs/ip_vs_sync.c | 4 ++-- 8 files changed, 36 insertions(+), 24 deletions(-)
include/net/ip_vs.h +6 -1
@@ -360,6 +360,7 @@ extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto);struct ip_vs_conn_param {const union nf_inet_addr *caddr;const union nf_inet_addr *vaddr; +__be32 fwmark;__be16 cport;__be16 vport;__u16 protocol;
@@ -381,6 +382,7 @@ struct ip_vs_conn {union nf_inet_addr caddr;/* client address */ union nf_inet_addr vaddr;/* virtual address */ union nf_inet_addr daddr;/* destination address */ +__be32 fwmark;/* fw mark for service */ volatile __u32 flags;/* status flags */ __be16 cport;__be16 vport;
@@ -679,6 +681,7 @@ static inline void ip_vs_conn_fill_param(int af, int protocol,__be16 cport, const union nf_inet_addr *vaddr, __be16 vport, + __be32 fwmark, struct ip_vs_conn_param *p) { p->af = af;
@@ -687,6 +690,7 @@ static inline void ip_vs_conn_fill_param(int af, int protocol, p->cport = cport; p->vaddr = vaddr; p->vport = vport; + p->fwmark = fwmark; p->pe =NULL ; p->pe_data =NULL ; }
@@ -889,7 +893,8 @@ extern int ip_vs_control_init(void);extern void ip_vs_control_cleanup (void );extern struct ip_vs_dest *ip_vs_find_dest (int af,const union nf_inet_addr *daddr,__be16 dport, -const union nf_inet_addr *vaddr,__be16 vport,__u16 protocol); +const union nf_inet_addr *vaddr,__be16 vport,__u16 protocol, +__u32 fwmark);extern struct ip_vs_dest *ip_vs_try_bind_dest (struct ip_vs_conn *cp);
net/netfilter/ipvs/ip_vs_conn.c +5 -4
@@ -174,7 +174,7 @@ static unsigned int ip_vs_conn_hashkey_conn(const struct ip_vs_conn *cp)struct ip_vs_conn_param p;ip_vs_conn_fill_param (cp->af, cp->protocol, &cp->caddr, cp->cport, -NULL ,0 , &p); +NULL ,0 ,0 , &p);if (cp->dest && cp->dest->svc->pe) { p.pe = cp->dest->svc->pe;
@@ -320,10 +320,10 @@ ip_vs_conn_fill_param_proto(int af, const struct sk_buff *skb,if (likely (!inverse))ip_vs_conn_fill_param (af, iph->protocol, &iph->saddr, pptr[0 ], - &iph->daddr, pptr[1 ], p); + &iph->daddr, pptr[1 ], skb->mark, p);else ip_vs_conn_fill_param (af, iph->protocol, &iph->daddr, pptr[1 ], - &iph->saddr, pptr[0 ], p); + &iph->saddr, pptr[0 ], skb->mark, p);return 0 ; }
@@ -613,7 +613,7 @@ struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)if ((cp) && (!cp->dest)) { dest =ip_vs_find_dest (cp->af, &cp->daddr, cp->dport, &cp->vaddr, cp->vport, - cp->protocol); + cp->protocol, cp->fwmark);ip_vs_bind_dest (cp, dest);return dest; }else
@@ -825,6 +825,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,ip_vs_addr_copy (p->protocol ==IPPROTO_IP ?AF_UNSPEC : p->af, &cp->daddr, daddr); cp->dport = dport; + cp->fwmark = p->fwmark; cp->flags = flags;if (flags &IP_VS_CONN_F_TEMPLATE && p->pe_data) { cp->pe_data = p->pe_data;
net/netfilter/ipvs/ip_vs_core.c +7 -6
@@ -184,7 +184,8 @@ ip_vs_conn_fill_param_persist(const struct ip_vs_service *svc, const union nf_inet_addr *vaddr, __be16 vport, struct ip_vs_conn_param *p) { - ip_vs_conn_fill_param(svc->af, protocol, caddr, cport, vaddr, vport, p); + ip_vs_conn_fill_param(svc->af, protocol, caddr, cport, vaddr, vport, + skb->mark, p); p->pe = svc->pe;if (p->pe && p->pe->fill_param) p->pe->fill_param (p, skb);
@@ -318,7 +319,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,* Create a new connection according to the template */ ip_vs_conn_fill_param (svc->af, iph.protocol, &iph.saddr, ports[0 ], - &iph.daddr, ports[1 ], ¶m); + &iph.daddr, ports[1 ], skb->mark, ¶m); cp =ip_vs_conn_new (¶m, &dest->addr, dport, flags, dest);if (cp ==NULL ) {ip_vs_conn_put (ct);
@@ -419,8 +420,8 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,*/ {struct ip_vs_conn_param p; -ip_vs_conn_fill_param (svc->af, iph.protocol, &iph.saddr, - pptr[0 ], &iph.daddr, pptr[1 ], &p); +ip_vs_conn_fill_param (svc->af, iph.protocol, &iph.saddr, pptr[0 ], + &iph.daddr, pptr[1 ], skb->mark, &p); cp =ip_vs_conn_new (&p, &dest->addr, dest->port ? dest->port : pptr[1 ], flags, dest);
@@ -485,8 +486,8 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, {struct ip_vs_conn_param p;ip_vs_conn_fill_param (svc->af, iph.protocol, - &iph.saddr, pptr[0 ], - &iph.daddr, pptr[1 ], &p); + &iph.saddr, pptr[0 ],&iph.daddr, + pptr[1 ], skb->mark, &p); cp =ip_vs_conn_new (&p, &daddr,0 ,IP_VS_CONN_F_BYPASS | flags,NULL );
net/netfilter/ipvs/ip_vs_ctl.c +2 -2
@@ -657,12 +657,12 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, const union nf_inet_addr *daddr,struct ip_vs_dest *ip_vs_find_dest (int af,const union nf_inet_addr *daddr,__be16 dport,const union nf_inet_addr *vaddr, -__be16 vport,__u16 protocol) +__be16 vport,__u16 protocol,__u32 fwmark) {struct ip_vs_dest *dest;struct ip_vs_service *svc; - svc =ip_vs_service_get (af,0 , protocol, vaddr, vport); + svc =ip_vs_service_get (af, fwmark, protocol, vaddr, vport);if (!svc)return NULL ; dest =ip_vs_lookup_dest (svc, daddr, dport);
net/netfilter/ipvs/ip_vs_ftp.c +5 -3
@@ -198,13 +198,15 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp, {struct ip_vs_conn_param p;ip_vs_conn_fill_param (AF_INET , iph->protocol, - &from, port, &cp->caddr,0 , &p); + &from, port, &cp->caddr, +0 , skb->mark, &p); n_cp =ip_vs_conn_out_get (&p); }if (!n_cp) {struct ip_vs_conn_param p;ip_vs_conn_fill_param (AF_INET ,IPPROTO_TCP , &cp->caddr, -0 , &cp->vaddr, port, &p); +0 , &cp->vaddr, port, + skb->mark, &p); n_cp = ip_vs_conn_new(&p, &from, port, IP_VS_CONN_F_NO_CPORT | IP_VS_CONN_F_NFCT,
@@ -360,7 +362,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,struct ip_vs_conn_param p;ip_vs_conn_fill_param (AF_INET , iph->protocol, &to, port, &cp->vaddr,htons (ntohs (cp->vport)-1 ), - &p); + skb->mark, &p); n_cp =ip_vs_conn_in_get (&p);if (!n_cp) { n_cp = ip_vs_conn_new(&p, &cp->daddr,
net/netfilter/ipvs/ip_vs_nfct.c +1 -1
@@ -157,7 +157,7 @@ static void ip_vs_nfct_expect_callback(struct nf_conn *ct, orig = &ct->tuplehash[IP_CT_DIR_ORIGINAL ].tuple;ip_vs_conn_fill_param (exp->tuple.src.l3num, orig->dst.protonum, &orig->src.u3, orig->src.u.tcp.port, - &orig->dst.u3, orig->dst.u.tcp.port, &p); + &orig->dst.u3, orig->dst.u.tcp.port,0 , &p); cp =ip_vs_conn_out_get (&p);if (cp) {/* Change reply CLIENT->RS to CLIENT->VS */
net/netfilter/ipvs/ip_vs_proto_ah_esp.c +8 -5
@@ -42,16 +42,19 @@ struct isakmp_hdr {static void ah_esp_conn_fill_param_proto (int af,const struct ip_vs_iphdr *iph, -int inverse,struct ip_vs_conn_param *p) +int inverse,const struct sk_buff *skb, +struct ip_vs_conn_param *p) {if (likely (!inverse))ip_vs_conn_fill_param (af,IPPROTO_UDP , &iph->saddr,htons (PORT_ISAKMP ), - &iph->daddr,htons (PORT_ISAKMP ), p); + &iph->daddr,htons (PORT_ISAKMP ), + skb->mark, p);else ip_vs_conn_fill_param (af,IPPROTO_UDP , &iph->daddr,htons (PORT_ISAKMP ), - &iph->saddr,htons (PORT_ISAKMP ), p); + &iph->saddr,htons (PORT_ISAKMP ), + skb->mark, p); } static struct ip_vs_conn *
@@ -62,7 +65,7 @@ ah_esp_conn_in_get(int af, const struct sk_buff *skb, struct ip_vs_protocol *pp,struct ip_vs_conn *cp;struct ip_vs_conn_param p; -ah_esp_conn_fill_param_proto (af, iph, inverse, &p); +ah_esp_conn_fill_param_proto (af, iph, inverse, skb, &p); cp =ip_vs_conn_in_get (&p);if (!cp) {/*
@@ -91,7 +94,7 @@ ah_esp_conn_out_get(int af, const struct sk_buff *skb,struct ip_vs_conn *cp;struct ip_vs_conn_param p; -ah_esp_conn_fill_param_proto (af, iph, inverse, &p); +ah_esp_conn_fill_param_proto (af, iph, inverse, skb, &p); cp =ip_vs_conn_out_get (&p);if (!cp) { IP_VS_DBG_BUF(12, "Unknown ISAKMP entry for inout packet "
net/netfilter/ipvs/ip_vs_sync.c +2 -2
@@ -295,7 +295,7 @@ ip_vs_conn_fill_param_sync(int af, int protocol, struct ip_vs_conn_param *p) {/* XXX: Need to take into account persistence engine */ -ip_vs_conn_fill_param (af, protocol, caddr, cport, vaddr, vport, p); +ip_vs_conn_fill_param (af, protocol, caddr, cport, vaddr, vport,0 , p);return 0 ; }
@@ -406,7 +406,7 @@ static void ip_vs_process_message(const char *buffer, const size_t buflen) s->dport, (union nf_inet_addr *)&s->vaddr, s->vport, - s->protocol); + s->protocol, 0);/* Set the approprite ativity flag */ if (s->protocol ==IPPROTO_TCP ) {if (state !=IP_VS_TCP_S_ESTABLISHED )
Signature · 1 line
1.6.0.2
Simon Horman
maintainerQuoted 6 lines · Hans Schillstrom
Two structs will have fwmark added:
*ip_vs_conn
*ip_vs_conn_param
ip_vs_conn_fill_paramwill have an extra param - fwmark The effects of that is in this patch.
This looks good to me, with the exception of
the minor formatting nit below.
I have fixed it as I describe below and queued it up for nf-next-2.6 once it opens.
Quoted 1 line
Signed-off-by Hans Schillstrom <[email protected]>
[ snip ]
Quoted 4 lines
net/netfilter/ipvs/ip_vs_core.c +0
-0
[ snip ]
net/netfilter/ipvs/ip_vs_core.c int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, · line 490
Quoted 8 lines
net/netfilter/ipvs/ip_vs_core.c +2
-2@@ -485,8 +486,8 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, {struct ip_vs_conn_param p;ip_vs_conn_fill_param (svc->af, iph.protocol, - &iph.saddr, pptr[0 ], - &iph.daddr, pptr[1 ], &p); + &iph.saddr, pptr[0 ],&iph.daddr, + pptr[1 ], skb->mark, &p);
Could you please put a space after the ,?
For the record, the following is my preferred formatting.
ip_vs_conn_fill_param(svc->af, iph.protocol, &iph.saddr, pptr[0], &iph.daddr, pptr[1], skb->mark, &p);
Quoted 3 lines
net/netfilter/ipvs/ip_vs_core.c +0
-0cp =ip_vs_conn_new (&p, &daddr,0 ,IP_VS_CONN_F_BYPASS | flags,NULL );
[ snip ]
Hello,
Quoted 25 lines · On Thursday 28 October 2010 14:08:47 Simon Horman wrote:
Quoted 6 lines · Hans Schillstrom
Two structs will have fwmark added:
*ip_vs_conn
*ip_vs_conn_param
ip_vs_conn_fill_paramwill have an extra param - fwmark The effects of that is in this patch.This looks good to me, with the exception of
the minor formatting nit below.I have fixed it as I describe below and queued it up for nf-next-2.6 once it opens.
Quoted 1 line
Signed-off-by Hans Schillstrom <[email protected]>[ snip ]
Quoted 4 lines
net/netfilter/ipvs/ip_vs_core.c +0
-0[ snip ]
Quoted 11 lines
net/netfilter/ipvs/ip_vs_core.c int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, · line 490
Quoted 8 lines
net/netfilter/ipvs/ip_vs_core.c +2
-2@@ -485,8 +486,8 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, {struct ip_vs_conn_param p;ip_vs_conn_fill_param (svc->af, iph.protocol, - &iph.saddr, pptr[0 ], - &iph.daddr, pptr[1 ], &p); + &iph.saddr, pptr[0 ],&iph.daddr, + pptr[1 ], skb->mark, &p);Could you please put a space after the ,?
For the record, the following is my preferred formatting.
I prefer that too ;-)
I will prepare and send a version 2 of the patch set today, with the comments included from you and Julian.
--
Regards
Hans Schillstrom <[email protected]>
Hello again
On Thursday 28 October 2010 14:51:55 Hans Schillstrom wrote:
[snip]
Quoted 4 lines
I will prepare and send a version 2 of the patch set today, with the comments included from you and Julian.
May I should wait, for the "sync_option" answer first, If it should be remove it will affect the patch ...
--
Regards
Hans Schillstrom <[email protected]>
Simon Horman
maintainerQuoted 9 lines · Hans Schillstrom
Hello again
On Thursday 28 October 2010 14:51:55 Hans Schillstrom wrote:
[snip]Quoted 4 lines
I will prepare and send a version 2 of the patch set today, with the comments included from you and Julian.
May I should wait, for the "
sync_option" answer first, If it should be remove it will affect the patch ...
I think that you have already resent the patch series and it is somewhere further down my inbox.
But in general I don't think there is any particular rush as its going to be a long time before the 2.6.38 merge window opens up and I'm not sure that anyone is doing significant LVS work outside of sync and netns at this time.