Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7ade46a authored by Julius Volz's avatar Julius Volz Committed by Simon Horman
Browse files

IPVS: Change IPVS data structures to support IPv6 addresses



Introduce new 'af' fields into IPVS data structures for specifying an
entry's address family. Convert IP addresses to be of type union
nf_inet_addr.

Signed-off-by: default avatarJulius Volz <juliusv@google.com>
Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
parent fab0de02
Loading
Loading
Loading
Loading
+12 −6
Original line number Original line Diff line number Diff line
@@ -21,6 +21,9 @@
#include <linux/timer.h>
#include <linux/timer.h>


#include <net/checksum.h>
#include <net/checksum.h>
#include <linux/netfilter.h>		/* for union nf_inet_addr */
#include <linux/ipv6.h>			/* for struct ipv6hdr */
#include <net/ipv6.h>			/* for ipv6_addr_copy */


#ifdef CONFIG_IP_VS_DEBUG
#ifdef CONFIG_IP_VS_DEBUG
#include <linux/net.h>
#include <linux/net.h>
@@ -259,9 +262,10 @@ struct ip_vs_conn {
	struct list_head        c_list;         /* hashed list heads */
	struct list_head        c_list;         /* hashed list heads */


	/* Protocol, addresses and port numbers */
	/* Protocol, addresses and port numbers */
	__be32                   caddr;          /* client address */
	u16                      af;		/* address family */
	__be32                   vaddr;          /* virtual address */
	union nf_inet_addr       caddr;          /* client address */
	__be32                   daddr;          /* destination address */
	union nf_inet_addr       vaddr;          /* virtual address */
	union nf_inet_addr       daddr;          /* destination address */
	__be16                   cport;
	__be16                   cport;
	__be16                   vport;
	__be16                   vport;
	__be16                   dport;
	__be16                   dport;
@@ -314,8 +318,9 @@ struct ip_vs_service {
	atomic_t		refcnt;   /* reference counter */
	atomic_t		refcnt;   /* reference counter */
	atomic_t		usecnt;   /* use counter */
	atomic_t		usecnt;   /* use counter */


	u16			af;       /* address family */
	__u16			protocol; /* which protocol (TCP/UDP) */
	__u16			protocol; /* which protocol (TCP/UDP) */
	__be32			addr;	  /* IP address for virtual service */
	union nf_inet_addr	addr;	  /* IP address for virtual service */
	__be16			port;	  /* port number for the service */
	__be16			port;	  /* port number for the service */
	__u32                   fwmark;   /* firewall mark of the service */
	__u32                   fwmark;   /* firewall mark of the service */
	unsigned		flags;	  /* service status flags */
	unsigned		flags;	  /* service status flags */
@@ -342,7 +347,8 @@ struct ip_vs_dest {
	struct list_head	n_list;   /* for the dests in the service */
	struct list_head	n_list;   /* for the dests in the service */
	struct list_head	d_list;   /* for table with all the dests */
	struct list_head	d_list;   /* for table with all the dests */


	__be32			addr;		/* IP address of the server */
	u16			af;		/* address family */
	union nf_inet_addr	addr;		/* IP address of the server */
	__be16			port;		/* port number of the server */
	__be16			port;		/* port number of the server */
	volatile unsigned	flags;		/* dest status flags */
	volatile unsigned	flags;		/* dest status flags */
	atomic_t		conn_flags;	/* flags to copy to conn */
	atomic_t		conn_flags;	/* flags to copy to conn */
@@ -366,7 +372,7 @@ struct ip_vs_dest {
	/* for virtual service */
	/* for virtual service */
	struct ip_vs_service	*svc;		/* service it belongs to */
	struct ip_vs_service	*svc;		/* service it belongs to */
	__u16			protocol;	/* which protocol (TCP/UDP) */
	__u16			protocol;	/* which protocol (TCP/UDP) */
	__be32			vaddr;		/* virtual IP address */
	union nf_inet_addr	vaddr;		/* virtual IP address */
	__be16			vport;		/* virtual port number */
	__be16			vport;		/* virtual port number */
	__u32			vfwmark;	/* firewall mark of service */
	__u32			vfwmark;	/* firewall mark of service */
};
};
+30 −30
Original line number Original line Diff line number Diff line
@@ -131,7 +131,7 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
	int ret;
	int ret;


	/* Hash by protocol, client address and port */
	/* Hash by protocol, client address and port */
	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr.ip, cp->cport);


	ct_write_lock(hash);
	ct_write_lock(hash);


@@ -162,7 +162,7 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
	int ret;
	int ret;


	/* unhash it and decrease its reference counter */
	/* unhash it and decrease its reference counter */
	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr, cp->cport);
	hash = ip_vs_conn_hashkey(cp->protocol, cp->caddr.ip, cp->cport);


	ct_write_lock(hash);
	ct_write_lock(hash);


@@ -197,8 +197,8 @@ static inline struct ip_vs_conn *__ip_vs_conn_in_get
	ct_read_lock(hash);
	ct_read_lock(hash);


	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
		if (s_addr==cp->caddr && s_port==cp->cport &&
		if (s_addr == cp->caddr.ip && s_port == cp->cport &&
		    d_port==cp->vport && d_addr==cp->vaddr &&
		    d_port == cp->vport && d_addr == cp->vaddr.ip &&
		    ((!s_port) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
		    ((!s_port) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
		    protocol == cp->protocol) {
		    protocol == cp->protocol) {
			/* HIT */
			/* HIT */
@@ -243,8 +243,8 @@ struct ip_vs_conn *ip_vs_ct_in_get
	ct_read_lock(hash);
	ct_read_lock(hash);


	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
		if (s_addr==cp->caddr && s_port==cp->cport &&
		if (s_addr == cp->caddr.ip && s_port == cp->cport &&
		    d_port==cp->vport && d_addr==cp->vaddr &&
		    d_port == cp->vport && d_addr == cp->vaddr.ip &&
		    cp->flags & IP_VS_CONN_F_TEMPLATE &&
		    cp->flags & IP_VS_CONN_F_TEMPLATE &&
		    protocol == cp->protocol) {
		    protocol == cp->protocol) {
			/* HIT */
			/* HIT */
@@ -286,8 +286,8 @@ struct ip_vs_conn *ip_vs_conn_out_get
	ct_read_lock(hash);
	ct_read_lock(hash);


	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
	list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
		if (d_addr == cp->caddr && d_port == cp->cport &&
		if (d_addr == cp->caddr.ip && d_port == cp->cport &&
		    s_port == cp->dport && s_addr == cp->daddr &&
		    s_port == cp->dport && s_addr == cp->daddr.ip &&
		    protocol == cp->protocol) {
		    protocol == cp->protocol) {
			/* HIT */
			/* HIT */
			atomic_inc(&cp->refcnt);
			atomic_inc(&cp->refcnt);
@@ -406,9 +406,9 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
		  "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d "
		  "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d "
		  "dest->refcnt:%d\n",
		  "dest->refcnt:%d\n",
		  ip_vs_proto_name(cp->protocol),
		  ip_vs_proto_name(cp->protocol),
		  NIPQUAD(cp->caddr), ntohs(cp->cport),
		  NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
		  NIPQUAD(cp->vaddr), ntohs(cp->vport),
		  NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
		  NIPQUAD(cp->daddr), ntohs(cp->dport),
		  NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
		  ip_vs_fwd_tag(cp), cp->state,
		  ip_vs_fwd_tag(cp), cp->state,
		  cp->flags, atomic_read(&cp->refcnt),
		  cp->flags, atomic_read(&cp->refcnt),
		  atomic_read(&dest->refcnt));
		  atomic_read(&dest->refcnt));
@@ -444,8 +444,8 @@ struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)
	struct ip_vs_dest *dest;
	struct ip_vs_dest *dest;


	if ((cp) && (!cp->dest)) {
	if ((cp) && (!cp->dest)) {
		dest = ip_vs_find_dest(cp->daddr, cp->dport,
		dest = ip_vs_find_dest(cp->daddr.ip, cp->dport,
				       cp->vaddr, cp->vport, cp->protocol);
				       cp->vaddr.ip, cp->vport, cp->protocol);
		ip_vs_bind_dest(cp, dest);
		ip_vs_bind_dest(cp, dest);
		return dest;
		return dest;
	} else
	} else
@@ -468,9 +468,9 @@ static inline void ip_vs_unbind_dest(struct ip_vs_conn *cp)
		  "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d "
		  "d:%u.%u.%u.%u:%d fwd:%c s:%u conn->flags:%X conn->refcnt:%d "
		  "dest->refcnt:%d\n",
		  "dest->refcnt:%d\n",
		  ip_vs_proto_name(cp->protocol),
		  ip_vs_proto_name(cp->protocol),
		  NIPQUAD(cp->caddr), ntohs(cp->cport),
		  NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
		  NIPQUAD(cp->vaddr), ntohs(cp->vport),
		  NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
		  NIPQUAD(cp->daddr), ntohs(cp->dport),
		  NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
		  ip_vs_fwd_tag(cp), cp->state,
		  ip_vs_fwd_tag(cp), cp->state,
		  cp->flags, atomic_read(&cp->refcnt),
		  cp->flags, atomic_read(&cp->refcnt),
		  atomic_read(&dest->refcnt));
		  atomic_read(&dest->refcnt));
@@ -530,9 +530,9 @@ int ip_vs_check_template(struct ip_vs_conn *ct)
			  "protocol %s s:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d "
			  "protocol %s s:%u.%u.%u.%u:%d v:%u.%u.%u.%u:%d "
			  "-> d:%u.%u.%u.%u:%d\n",
			  "-> d:%u.%u.%u.%u:%d\n",
			  ip_vs_proto_name(ct->protocol),
			  ip_vs_proto_name(ct->protocol),
			  NIPQUAD(ct->caddr), ntohs(ct->cport),
			  NIPQUAD(ct->caddr.ip), ntohs(ct->cport),
			  NIPQUAD(ct->vaddr), ntohs(ct->vport),
			  NIPQUAD(ct->vaddr.ip), ntohs(ct->vport),
			  NIPQUAD(ct->daddr), ntohs(ct->dport));
			  NIPQUAD(ct->daddr.ip), ntohs(ct->dport));


		/*
		/*
		 * Invalidate the connection template
		 * Invalidate the connection template
@@ -641,11 +641,11 @@ ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport
	INIT_LIST_HEAD(&cp->c_list);
	INIT_LIST_HEAD(&cp->c_list);
	setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
	setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
	cp->protocol	   = proto;
	cp->protocol	   = proto;
	cp->caddr	   = caddr;
	cp->caddr.ip	   = caddr;
	cp->cport	   = cport;
	cp->cport	   = cport;
	cp->vaddr	   = vaddr;
	cp->vaddr.ip	   = vaddr;
	cp->vport	   = vport;
	cp->vport	   = vport;
	cp->daddr          = daddr;
	cp->daddr.ip	   = daddr;
	cp->dport          = dport;
	cp->dport          = dport;
	cp->flags	   = flags;
	cp->flags	   = flags;
	spin_lock_init(&cp->lock);
	spin_lock_init(&cp->lock);
@@ -763,9 +763,9 @@ static int ip_vs_conn_seq_show(struct seq_file *seq, void *v)
		seq_printf(seq,
		seq_printf(seq,
			"%-3s %08X %04X %08X %04X %08X %04X %-11s %7lu\n",
			"%-3s %08X %04X %08X %04X %08X %04X %-11s %7lu\n",
				ip_vs_proto_name(cp->protocol),
				ip_vs_proto_name(cp->protocol),
				ntohl(cp->caddr), ntohs(cp->cport),
				ntohl(cp->caddr.ip), ntohs(cp->cport),
				ntohl(cp->vaddr), ntohs(cp->vport),
				ntohl(cp->vaddr.ip), ntohs(cp->vport),
				ntohl(cp->daddr), ntohs(cp->dport),
				ntohl(cp->daddr.ip), ntohs(cp->dport),
				ip_vs_state_name(cp->protocol, cp->state),
				ip_vs_state_name(cp->protocol, cp->state),
				(cp->timer.expires-jiffies)/HZ);
				(cp->timer.expires-jiffies)/HZ);
	}
	}
@@ -812,9 +812,9 @@ static int ip_vs_conn_sync_seq_show(struct seq_file *seq, void *v)
		seq_printf(seq,
		seq_printf(seq,
			"%-3s %08X %04X %08X %04X %08X %04X %-11s %-6s %7lu\n",
			"%-3s %08X %04X %08X %04X %08X %04X %-11s %-6s %7lu\n",
				ip_vs_proto_name(cp->protocol),
				ip_vs_proto_name(cp->protocol),
				ntohl(cp->caddr), ntohs(cp->cport),
				ntohl(cp->caddr.ip), ntohs(cp->cport),
				ntohl(cp->vaddr), ntohs(cp->vport),
				ntohl(cp->vaddr.ip), ntohs(cp->vport),
				ntohl(cp->daddr), ntohs(cp->dport),
				ntohl(cp->daddr.ip), ntohs(cp->dport),
				ip_vs_state_name(cp->protocol, cp->state),
				ip_vs_state_name(cp->protocol, cp->state),
				ip_vs_origin_name(cp->flags),
				ip_vs_origin_name(cp->flags),
				(cp->timer.expires-jiffies)/HZ);
				(cp->timer.expires-jiffies)/HZ);
+14 −14
Original line number Original line Diff line number Diff line
@@ -232,14 +232,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
						    snet, 0,
						    snet, 0,
						    iph->daddr,
						    iph->daddr,
						    ports[1],
						    ports[1],
						    dest->addr, dest->port,
						    dest->addr.ip, dest->port,
						    IP_VS_CONN_F_TEMPLATE,
						    IP_VS_CONN_F_TEMPLATE,
						    dest);
						    dest);
			else
			else
				ct = ip_vs_conn_new(iph->protocol,
				ct = ip_vs_conn_new(iph->protocol,
						    snet, 0,
						    snet, 0,
						    iph->daddr, 0,
						    iph->daddr, 0,
						    dest->addr, 0,
						    dest->addr.ip, 0,
						    IP_VS_CONN_F_TEMPLATE,
						    IP_VS_CONN_F_TEMPLATE,
						    dest);
						    dest);
			if (ct == NULL)
			if (ct == NULL)
@@ -286,14 +286,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
				ct = ip_vs_conn_new(IPPROTO_IP,
				ct = ip_vs_conn_new(IPPROTO_IP,
						    snet, 0,
						    snet, 0,
						    htonl(svc->fwmark), 0,
						    htonl(svc->fwmark), 0,
						    dest->addr, 0,
						    dest->addr.ip, 0,
						    IP_VS_CONN_F_TEMPLATE,
						    IP_VS_CONN_F_TEMPLATE,
						    dest);
						    dest);
			else
			else
				ct = ip_vs_conn_new(iph->protocol,
				ct = ip_vs_conn_new(iph->protocol,
						    snet, 0,
						    snet, 0,
						    iph->daddr, 0,
						    iph->daddr, 0,
						    dest->addr, 0,
						    dest->addr.ip, 0,
						    IP_VS_CONN_F_TEMPLATE,
						    IP_VS_CONN_F_TEMPLATE,
						    dest);
						    dest);
			if (ct == NULL)
			if (ct == NULL)
@@ -313,7 +313,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
	cp = ip_vs_conn_new(iph->protocol,
	cp = ip_vs_conn_new(iph->protocol,
			    iph->saddr, ports[0],
			    iph->saddr, ports[0],
			    iph->daddr, ports[1],
			    iph->daddr, ports[1],
			    dest->addr, dport,
			    dest->addr.ip, dport,
			    0,
			    0,
			    dest);
			    dest);
	if (cp == NULL) {
	if (cp == NULL) {
@@ -380,7 +380,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
	cp = ip_vs_conn_new(iph->protocol,
	cp = ip_vs_conn_new(iph->protocol,
			    iph->saddr, pptr[0],
			    iph->saddr, pptr[0],
			    iph->daddr, pptr[1],
			    iph->daddr, pptr[1],
			    dest->addr, dest->port?dest->port:pptr[1],
			    dest->addr.ip, dest->port ? dest->port : pptr[1],
			    0,
			    0,
			    dest);
			    dest);
	if (cp == NULL)
	if (cp == NULL)
@@ -389,9 +389,9 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
	IP_VS_DBG(6, "Schedule fwd:%c c:%u.%u.%u.%u:%u v:%u.%u.%u.%u:%u "
	IP_VS_DBG(6, "Schedule fwd:%c c:%u.%u.%u.%u:%u v:%u.%u.%u.%u:%u "
		  "d:%u.%u.%u.%u:%u conn->flags:%X conn->refcnt:%d\n",
		  "d:%u.%u.%u.%u:%u conn->flags:%X conn->refcnt:%d\n",
		  ip_vs_fwd_tag(cp),
		  ip_vs_fwd_tag(cp),
		  NIPQUAD(cp->caddr), ntohs(cp->cport),
		  NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
		  NIPQUAD(cp->vaddr), ntohs(cp->vport),
		  NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
		  NIPQUAD(cp->daddr), ntohs(cp->dport),
		  NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
		  cp->flags, atomic_read(&cp->refcnt));
		  cp->flags, atomic_read(&cp->refcnt));


	ip_vs_conn_stats(cp, svc);
	ip_vs_conn_stats(cp, svc);
@@ -526,14 +526,14 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
	struct iphdr *ciph	 = (struct iphdr *)(icmph + 1);
	struct iphdr *ciph	 = (struct iphdr *)(icmph + 1);


	if (inout) {
	if (inout) {
		iph->saddr = cp->vaddr;
		iph->saddr = cp->vaddr.ip;
		ip_send_check(iph);
		ip_send_check(iph);
		ciph->daddr = cp->vaddr;
		ciph->daddr = cp->vaddr.ip;
		ip_send_check(ciph);
		ip_send_check(ciph);
	} else {
	} else {
		iph->daddr = cp->daddr;
		iph->daddr = cp->daddr.ip;
		ip_send_check(iph);
		ip_send_check(iph);
		ciph->saddr = cp->daddr;
		ciph->saddr = cp->daddr.ip;
		ip_send_check(ciph);
		ip_send_check(ciph);
	}
	}


@@ -762,7 +762,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb,
	/* mangle the packet */
	/* mangle the packet */
	if (pp->snat_handler && !pp->snat_handler(skb, pp, cp))
	if (pp->snat_handler && !pp->snat_handler(skb, pp, cp))
		goto drop;
		goto drop;
	ip_hdr(skb)->saddr = cp->vaddr;
	ip_hdr(skb)->saddr = cp->vaddr.ip;
	ip_send_check(ip_hdr(skb));
	ip_send_check(ip_hdr(skb));


	/* For policy routing, packets originating from this
	/* For policy routing, packets originating from this
+19 −18
Original line number Original line Diff line number Diff line
@@ -317,7 +317,8 @@ static int ip_vs_svc_hash(struct ip_vs_service *svc)
		/*
		/*
		 *  Hash it by <protocol,addr,port> in ip_vs_svc_table
		 *  Hash it by <protocol,addr,port> in ip_vs_svc_table
		 */
		 */
		hash = ip_vs_svc_hashkey(svc->protocol, svc->addr, svc->port);
		hash = ip_vs_svc_hashkey(svc->protocol, svc->addr.ip,
					 svc->port);
		list_add(&svc->s_list, &ip_vs_svc_table[hash]);
		list_add(&svc->s_list, &ip_vs_svc_table[hash]);
	} else {
	} else {
		/*
		/*
@@ -373,7 +374,7 @@ __ip_vs_service_get(__u16 protocol, __be32 vaddr, __be16 vport)
	hash = ip_vs_svc_hashkey(protocol, vaddr, vport);
	hash = ip_vs_svc_hashkey(protocol, vaddr, vport);


	list_for_each_entry(svc, &ip_vs_svc_table[hash], s_list){
	list_for_each_entry(svc, &ip_vs_svc_table[hash], s_list){
		if ((svc->addr == vaddr)
		if ((svc->addr.ip == vaddr)
		    && (svc->port == vport)
		    && (svc->port == vport)
		    && (svc->protocol == protocol)) {
		    && (svc->protocol == protocol)) {
			/* HIT */
			/* HIT */
@@ -503,7 +504,7 @@ static int ip_vs_rs_hash(struct ip_vs_dest *dest)
	 *	Hash by proto,addr,port,
	 *	Hash by proto,addr,port,
	 *	which are the parameters of the real service.
	 *	which are the parameters of the real service.
	 */
	 */
	hash = ip_vs_rs_hashkey(dest->addr, dest->port);
	hash = ip_vs_rs_hashkey(dest->addr.ip, dest->port);
	list_add(&dest->d_list, &ip_vs_rtable[hash]);
	list_add(&dest->d_list, &ip_vs_rtable[hash]);


	return 1;
	return 1;
@@ -543,7 +544,7 @@ ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport)


	read_lock(&__ip_vs_rs_lock);
	read_lock(&__ip_vs_rs_lock);
	list_for_each_entry(dest, &ip_vs_rtable[hash], d_list) {
	list_for_each_entry(dest, &ip_vs_rtable[hash], d_list) {
		if ((dest->addr == daddr)
		if ((dest->addr.ip == daddr)
		    && (dest->port == dport)
		    && (dest->port == dport)
		    && ((dest->protocol == protocol) ||
		    && ((dest->protocol == protocol) ||
			dest->vfwmark)) {
			dest->vfwmark)) {
@@ -569,7 +570,7 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
	 * Find the destination for the given service
	 * Find the destination for the given service
	 */
	 */
	list_for_each_entry(dest, &svc->destinations, n_list) {
	list_for_each_entry(dest, &svc->destinations, n_list) {
		if ((dest->addr == daddr) && (dest->port == dport)) {
		if ((dest->addr.ip == daddr) && (dest->port == dport)) {
			/* HIT */
			/* HIT */
			return dest;
			return dest;
		}
		}
@@ -626,14 +627,14 @@ ip_vs_trash_get_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
		IP_VS_DBG(3, "Destination %u/%u.%u.%u.%u:%u still in trash, "
		IP_VS_DBG(3, "Destination %u/%u.%u.%u.%u:%u still in trash, "
			  "dest->refcnt=%d\n",
			  "dest->refcnt=%d\n",
			  dest->vfwmark,
			  dest->vfwmark,
			  NIPQUAD(dest->addr), ntohs(dest->port),
			  NIPQUAD(dest->addr.ip), ntohs(dest->port),
			  atomic_read(&dest->refcnt));
			  atomic_read(&dest->refcnt));
		if (dest->addr == daddr &&
		if (dest->addr.ip == daddr &&
		    dest->port == dport &&
		    dest->port == dport &&
		    dest->vfwmark == svc->fwmark &&
		    dest->vfwmark == svc->fwmark &&
		    dest->protocol == svc->protocol &&
		    dest->protocol == svc->protocol &&
		    (svc->fwmark ||
		    (svc->fwmark ||
		     (dest->vaddr == svc->addr &&
		     (dest->vaddr.ip == svc->addr.ip &&
		      dest->vport == svc->port))) {
		      dest->vport == svc->port))) {
			/* HIT */
			/* HIT */
			return dest;
			return dest;
@@ -646,7 +647,7 @@ ip_vs_trash_get_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
			IP_VS_DBG(3, "Removing destination %u/%u.%u.%u.%u:%u "
			IP_VS_DBG(3, "Removing destination %u/%u.%u.%u.%u:%u "
				  "from trash\n",
				  "from trash\n",
				  dest->vfwmark,
				  dest->vfwmark,
				  NIPQUAD(dest->addr), ntohs(dest->port));
				  NIPQUAD(dest->addr.ip), ntohs(dest->port));
			list_del(&dest->n_list);
			list_del(&dest->n_list);
			ip_vs_dst_reset(dest);
			ip_vs_dst_reset(dest);
			__ip_vs_unbind_svc(dest);
			__ip_vs_unbind_svc(dest);
@@ -779,10 +780,10 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest,
	}
	}


	dest->protocol = svc->protocol;
	dest->protocol = svc->protocol;
	dest->vaddr = svc->addr;
	dest->vaddr.ip = svc->addr.ip;
	dest->vport = svc->port;
	dest->vport = svc->port;
	dest->vfwmark = svc->fwmark;
	dest->vfwmark = svc->fwmark;
	dest->addr = udest->addr;
	dest->addr.ip = udest->addr;
	dest->port = udest->port;
	dest->port = udest->port;


	atomic_set(&dest->activeconns, 0);
	atomic_set(&dest->activeconns, 0);
@@ -847,7 +848,7 @@ ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest)
			  NIPQUAD(daddr), ntohs(dport),
			  NIPQUAD(daddr), ntohs(dport),
			  atomic_read(&dest->refcnt),
			  atomic_read(&dest->refcnt),
			  dest->vfwmark,
			  dest->vfwmark,
			  NIPQUAD(dest->vaddr),
			  NIPQUAD(dest->vaddr.ip),
			  ntohs(dest->vport));
			  ntohs(dest->vport));
		__ip_vs_update_dest(svc, dest, udest);
		__ip_vs_update_dest(svc, dest, udest);


@@ -993,7 +994,7 @@ static void __ip_vs_del_dest(struct ip_vs_dest *dest)
	} else {
	} else {
		IP_VS_DBG(3, "Moving dest %u.%u.%u.%u:%u into trash, "
		IP_VS_DBG(3, "Moving dest %u.%u.%u.%u:%u into trash, "
			  "dest->refcnt=%d\n",
			  "dest->refcnt=%d\n",
			  NIPQUAD(dest->addr), ntohs(dest->port),
			  NIPQUAD(dest->addr.ip), ntohs(dest->port),
			  atomic_read(&dest->refcnt));
			  atomic_read(&dest->refcnt));
		list_add(&dest->n_list, &ip_vs_dest_trash);
		list_add(&dest->n_list, &ip_vs_dest_trash);
		atomic_inc(&dest->refcnt);
		atomic_inc(&dest->refcnt);
@@ -1101,7 +1102,7 @@ ip_vs_add_service(struct ip_vs_service_user *u, struct ip_vs_service **svc_p)
	atomic_set(&svc->refcnt, 0);
	atomic_set(&svc->refcnt, 0);


	svc->protocol = u->protocol;
	svc->protocol = u->protocol;
	svc->addr = u->addr;
	svc->addr.ip = u->addr;
	svc->port = u->port;
	svc->port = u->port;
	svc->fwmark = u->fwmark;
	svc->fwmark = u->fwmark;
	svc->flags = u->flags;
	svc->flags = u->flags;
@@ -1751,7 +1752,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
		if (iter->table == ip_vs_svc_table)
		if (iter->table == ip_vs_svc_table)
			seq_printf(seq, "%s  %08X:%04X %s ",
			seq_printf(seq, "%s  %08X:%04X %s ",
				   ip_vs_proto_name(svc->protocol),
				   ip_vs_proto_name(svc->protocol),
				   ntohl(svc->addr),
				   ntohl(svc->addr.ip),
				   ntohs(svc->port),
				   ntohs(svc->port),
				   svc->scheduler->name);
				   svc->scheduler->name);
		else
		else
@@ -1768,7 +1769,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
		list_for_each_entry(dest, &svc->destinations, n_list) {
		list_for_each_entry(dest, &svc->destinations, n_list) {
			seq_printf(seq,
			seq_printf(seq,
				   "  -> %08X:%04X      %-7s %-6d %-10d %-10d\n",
				   "  -> %08X:%04X      %-7s %-6d %-10d %-10d\n",
				   ntohl(dest->addr), ntohs(dest->port),
				   ntohl(dest->addr.ip), ntohs(dest->port),
				   ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
				   ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
				   atomic_read(&dest->weight),
				   atomic_read(&dest->weight),
				   atomic_read(&dest->activeconns),
				   atomic_read(&dest->activeconns),
@@ -2040,7 +2041,7 @@ static void
ip_vs_copy_service(struct ip_vs_service_entry *dst, struct ip_vs_service *src)
ip_vs_copy_service(struct ip_vs_service_entry *dst, struct ip_vs_service *src)
{
{
	dst->protocol = src->protocol;
	dst->protocol = src->protocol;
	dst->addr = src->addr;
	dst->addr = src->addr.ip;
	dst->port = src->port;
	dst->port = src->port;
	dst->fwmark = src->fwmark;
	dst->fwmark = src->fwmark;
	strlcpy(dst->sched_name, src->scheduler->name, sizeof(dst->sched_name));
	strlcpy(dst->sched_name, src->scheduler->name, sizeof(dst->sched_name));
@@ -2114,7 +2115,7 @@ __ip_vs_get_dest_entries(const struct ip_vs_get_dests *get,
			if (count >= get->num_dests)
			if (count >= get->num_dests)
				break;
				break;


			entry.addr = dest->addr;
			entry.addr = dest->addr.ip;
			entry.port = dest->port;
			entry.port = dest->port;
			entry.conn_flags = atomic_read(&dest->conn_flags);
			entry.conn_flags = atomic_read(&dest->conn_flags);
			entry.weight = atomic_read(&dest->weight);
			entry.weight = atomic_read(&dest->weight);
+1 −1
Original line number Original line Diff line number Diff line
@@ -218,7 +218,7 @@ ip_vs_dh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
	IP_VS_DBG(6, "DH: destination IP address %u.%u.%u.%u "
	IP_VS_DBG(6, "DH: destination IP address %u.%u.%u.%u "
		  "--> server %u.%u.%u.%u:%d\n",
		  "--> server %u.%u.%u.%u:%d\n",
		  NIPQUAD(iph->daddr),
		  NIPQUAD(iph->daddr),
		  NIPQUAD(dest->addr),
		  NIPQUAD(dest->addr.ip),
		  ntohs(dest->port));
		  ntohs(dest->port));


	return dest;
	return dest;
Loading