IPVS: Change IPVS data structures to support IPv6 addresses
authorJulius Volz <juliusv@google.com>
Tue, 2 Sep 2008 13:55:33 +0000 (15:55 +0200)
committerSimon Horman <horms@verge.net.au>
Fri, 5 Sep 2008 01:17:03 +0000 (11:17 +1000)
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: Julius Volz <juliusv@google.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
19 files changed:
include/net/ip_vs.h
net/ipv4/ipvs/ip_vs_conn.c
net/ipv4/ipvs/ip_vs_core.c
net/ipv4/ipvs/ip_vs_ctl.c
net/ipv4/ipvs/ip_vs_dh.c
net/ipv4/ipvs/ip_vs_ftp.c
net/ipv4/ipvs/ip_vs_lblc.c
net/ipv4/ipvs/ip_vs_lblcr.c
net/ipv4/ipvs/ip_vs_lc.c
net/ipv4/ipvs/ip_vs_nq.c
net/ipv4/ipvs/ip_vs_proto_tcp.c
net/ipv4/ipvs/ip_vs_proto_udp.c
net/ipv4/ipvs/ip_vs_rr.c
net/ipv4/ipvs/ip_vs_sed.c
net/ipv4/ipvs/ip_vs_sh.c
net/ipv4/ipvs/ip_vs_sync.c
net/ipv4/ipvs/ip_vs_wlc.c
net/ipv4/ipvs/ip_vs_wrr.c
net/ipv4/ipvs/ip_vs_xmit.c

index a25ad243031d3a1c2e0d66e1a01cb3f15b0aa86b..d32825585500eec6119807c0e89c82a4da61a272 100644 (file)
@@ -21,6 +21,9 @@
 #include <linux/timer.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
 #include <linux/net.h>
@@ -259,9 +262,10 @@ struct ip_vs_conn {
        struct list_head        c_list;         /* hashed list heads */
 
        /* Protocol, addresses and port numbers */
-       __be32                   caddr;          /* client address */
-       __be32                   vaddr;          /* virtual address */
-       __be32                   daddr;          /* destination address */
+       u16                      af;            /* address family */
+       union nf_inet_addr       caddr;          /* client address */
+       union nf_inet_addr       vaddr;          /* virtual address */
+       union nf_inet_addr       daddr;          /* destination address */
        __be16                   cport;
        __be16                   vport;
        __be16                   dport;
@@ -314,8 +318,9 @@ struct ip_vs_service {
        atomic_t                refcnt;   /* reference counter */
        atomic_t                usecnt;   /* use counter */
 
+       u16                     af;       /* address family */
        __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 */
        __u32                   fwmark;   /* firewall mark of the service */
        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        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 */
        volatile unsigned       flags;          /* dest status flags */
        atomic_t                conn_flags;     /* flags to copy to conn */
@@ -366,7 +372,7 @@ struct ip_vs_dest {
        /* for virtual service */
        struct ip_vs_service    *svc;           /* service it belongs to */
        __u16                   protocol;       /* which protocol (TCP/UDP) */
-       __be32                  vaddr;          /* virtual IP address */
+       union nf_inet_addr      vaddr;          /* virtual IP address */
        __be16                  vport;          /* virtual port number */
        __u32                   vfwmark;        /* firewall mark of service */
 };
index 44a6872dc24581b97f0338368aabb0c174fb5e0e..639d4bc7fc1dc73393b06cda95a61573cfb2a60d 100644 (file)
@@ -131,7 +131,7 @@ static inline int ip_vs_conn_hash(struct ip_vs_conn *cp)
        int ret;
 
        /* 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);
 
@@ -162,7 +162,7 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
        int ret;
 
        /* 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);
 
@@ -197,10 +197,10 @@ static inline struct ip_vs_conn *__ip_vs_conn_in_get
        ct_read_lock(hash);
 
        list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
-               if (s_addr==cp->caddr && s_port==cp->cport &&
-                   d_port==cp->vport && d_addr==cp->vaddr &&
+               if (s_addr == cp->caddr.ip && s_port == cp->cport &&
+                   d_port == cp->vport && d_addr == cp->vaddr.ip &&
                    ((!s_port) ^ (!(cp->flags & IP_VS_CONN_F_NO_CPORT))) &&
-                   protocol==cp->protocol) {
+                   protocol == cp->protocol) {
                        /* HIT */
                        atomic_inc(&cp->refcnt);
                        ct_read_unlock(hash);
@@ -243,10 +243,10 @@ struct ip_vs_conn *ip_vs_ct_in_get
        ct_read_lock(hash);
 
        list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
-               if (s_addr==cp->caddr && s_port==cp->cport &&
-                   d_port==cp->vport && d_addr==cp->vaddr &&
+               if (s_addr == cp->caddr.ip && s_port == cp->cport &&
+                   d_port == cp->vport && d_addr == cp->vaddr.ip &&
                    cp->flags & IP_VS_CONN_F_TEMPLATE &&
-                   protocol==cp->protocol) {
+                   protocol == cp->protocol) {
                        /* HIT */
                        atomic_inc(&cp->refcnt);
                        goto out;
@@ -286,8 +286,8 @@ struct ip_vs_conn *ip_vs_conn_out_get
        ct_read_lock(hash);
 
        list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
-               if (d_addr == cp->caddr && d_port == cp->cport &&
-                   s_port == cp->dport && s_addr == cp->daddr &&
+               if (d_addr == cp->caddr.ip && d_port == cp->cport &&
+                   s_port == cp->dport && s_addr == cp->daddr.ip &&
                    protocol == cp->protocol) {
                        /* HIT */
                        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 "
                  "dest->refcnt:%d\n",
                  ip_vs_proto_name(cp->protocol),
-                 NIPQUAD(cp->caddr), ntohs(cp->cport),
-                 NIPQUAD(cp->vaddr), ntohs(cp->vport),
-                 NIPQUAD(cp->daddr), ntohs(cp->dport),
+                 NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
+                 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
+                 NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
                  ip_vs_fwd_tag(cp), cp->state,
                  cp->flags, atomic_read(&cp->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;
 
        if ((cp) && (!cp->dest)) {
-               dest = ip_vs_find_dest(cp->daddr, cp->dport,
-                                      cp->vaddr, cp->vport, cp->protocol);
+               dest = ip_vs_find_dest(cp->daddr.ip, cp->dport,
+                                      cp->vaddr.ip, cp->vport, cp->protocol);
                ip_vs_bind_dest(cp, dest);
                return dest;
        } 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 "
                  "dest->refcnt:%d\n",
                  ip_vs_proto_name(cp->protocol),
-                 NIPQUAD(cp->caddr), ntohs(cp->cport),
-                 NIPQUAD(cp->vaddr), ntohs(cp->vport),
-                 NIPQUAD(cp->daddr), ntohs(cp->dport),
+                 NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
+                 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
+                 NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
                  ip_vs_fwd_tag(cp), cp->state,
                  cp->flags, atomic_read(&cp->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 "
                          "-> d:%u.%u.%u.%u:%d\n",
                          ip_vs_proto_name(ct->protocol),
-                         NIPQUAD(ct->caddr), ntohs(ct->cport),
-                         NIPQUAD(ct->vaddr), ntohs(ct->vport),
-                         NIPQUAD(ct->daddr), ntohs(ct->dport));
+                         NIPQUAD(ct->caddr.ip), ntohs(ct->cport),
+                         NIPQUAD(ct->vaddr.ip), ntohs(ct->vport),
+                         NIPQUAD(ct->daddr.ip), ntohs(ct->dport));
 
                /*
                 * 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);
        setup_timer(&cp->timer, ip_vs_conn_expire, (unsigned long)cp);
        cp->protocol       = proto;
-       cp->caddr          = caddr;
+       cp->caddr.ip       = caddr;
        cp->cport          = cport;
-       cp->vaddr          = vaddr;
+       cp->vaddr.ip       = vaddr;
        cp->vport          = vport;
-       cp->daddr          = daddr;
+       cp->daddr.ip       = daddr;
        cp->dport          = dport;
        cp->flags          = flags;
        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,
                        "%-3s %08X %04X %08X %04X %08X %04X %-11s %7lu\n",
                                ip_vs_proto_name(cp->protocol),
-                               ntohl(cp->caddr), ntohs(cp->cport),
-                               ntohl(cp->vaddr), ntohs(cp->vport),
-                               ntohl(cp->daddr), ntohs(cp->dport),
+                               ntohl(cp->caddr.ip), ntohs(cp->cport),
+                               ntohl(cp->vaddr.ip), ntohs(cp->vport),
+                               ntohl(cp->daddr.ip), ntohs(cp->dport),
                                ip_vs_state_name(cp->protocol, cp->state),
                                (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,
                        "%-3s %08X %04X %08X %04X %08X %04X %-11s %-6s %7lu\n",
                                ip_vs_proto_name(cp->protocol),
-                               ntohl(cp->caddr), ntohs(cp->cport),
-                               ntohl(cp->vaddr), ntohs(cp->vport),
-                               ntohl(cp->daddr), ntohs(cp->dport),
+                               ntohl(cp->caddr.ip), ntohs(cp->cport),
+                               ntohl(cp->vaddr.ip), ntohs(cp->vport),
+                               ntohl(cp->daddr.ip), ntohs(cp->dport),
                                ip_vs_state_name(cp->protocol, cp->state),
                                ip_vs_origin_name(cp->flags),
                                (cp->timer.expires-jiffies)/HZ);
index 9fbf0a6d73926fc0d133fe99f9b012fe041b5951..4a54f33b60d4f9b60be4f0db1af709ea98c17924 100644 (file)
@@ -232,14 +232,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
                                                    snet, 0,
                                                    iph->daddr,
                                                    ports[1],
-                                                   dest->addr, dest->port,
+                                                   dest->addr.ip, dest->port,
                                                    IP_VS_CONN_F_TEMPLATE,
                                                    dest);
                        else
                                ct = ip_vs_conn_new(iph->protocol,
                                                    snet, 0,
                                                    iph->daddr, 0,
-                                                   dest->addr, 0,
+                                                   dest->addr.ip, 0,
                                                    IP_VS_CONN_F_TEMPLATE,
                                                    dest);
                        if (ct == NULL)
@@ -286,14 +286,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
                                ct = ip_vs_conn_new(IPPROTO_IP,
                                                    snet, 0,
                                                    htonl(svc->fwmark), 0,
-                                                   dest->addr, 0,
+                                                   dest->addr.ip, 0,
                                                    IP_VS_CONN_F_TEMPLATE,
                                                    dest);
                        else
                                ct = ip_vs_conn_new(iph->protocol,
                                                    snet, 0,
                                                    iph->daddr, 0,
-                                                   dest->addr, 0,
+                                                   dest->addr.ip, 0,
                                                    IP_VS_CONN_F_TEMPLATE,
                                                    dest);
                        if (ct == NULL)
@@ -313,7 +313,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
        cp = ip_vs_conn_new(iph->protocol,
                            iph->saddr, ports[0],
                            iph->daddr, ports[1],
-                           dest->addr, dport,
+                           dest->addr.ip, dport,
                            0,
                            dest);
        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,
                            iph->saddr, pptr[0],
                            iph->daddr, pptr[1],
-                           dest->addr, dest->port?dest->port:pptr[1],
+                           dest->addr.ip, dest->port ? dest->port : pptr[1],
                            0,
                            dest);
        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 "
                  "d:%u.%u.%u.%u:%u conn->flags:%X conn->refcnt:%d\n",
                  ip_vs_fwd_tag(cp),
-                 NIPQUAD(cp->caddr), ntohs(cp->cport),
-                 NIPQUAD(cp->vaddr), ntohs(cp->vport),
-                 NIPQUAD(cp->daddr), ntohs(cp->dport),
+                 NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
+                 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
+                 NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
                  cp->flags, atomic_read(&cp->refcnt));
 
        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);
 
        if (inout) {
-               iph->saddr = cp->vaddr;
+               iph->saddr = cp->vaddr.ip;
                ip_send_check(iph);
-               ciph->daddr = cp->vaddr;
+               ciph->daddr = cp->vaddr.ip;
                ip_send_check(ciph);
        } else {
-               iph->daddr = cp->daddr;
+               iph->daddr = cp->daddr.ip;
                ip_send_check(iph);
-               ciph->saddr = cp->daddr;
+               ciph->saddr = cp->daddr.ip;
                ip_send_check(ciph);
        }
 
@@ -762,7 +762,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb,
        /* mangle the packet */
        if (pp->snat_handler && !pp->snat_handler(skb, pp, cp))
                goto drop;
-       ip_hdr(skb)->saddr = cp->vaddr;
+       ip_hdr(skb)->saddr = cp->vaddr.ip;
        ip_send_check(ip_hdr(skb));
 
        /* For policy routing, packets originating from this
index ede101eeec17d86b5bdc05903aecfed3e9ff3329..3f2277b847db92792a62cde2e51145262735fcef 100644 (file)
@@ -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 = 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]);
        } else {
                /*
@@ -373,7 +374,7 @@ __ip_vs_service_get(__u16 protocol, __be32 vaddr, __be16 vport)
        hash = ip_vs_svc_hashkey(protocol, vaddr, vport);
 
        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->protocol == protocol)) {
                        /* HIT */
@@ -503,7 +504,7 @@ static int ip_vs_rs_hash(struct ip_vs_dest *dest)
         *      Hash by proto,addr,port,
         *      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]);
 
        return 1;
@@ -543,7 +544,7 @@ ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport)
 
        read_lock(&__ip_vs_rs_lock);
        list_for_each_entry(dest, &ip_vs_rtable[hash], d_list) {
-               if ((dest->addr == daddr)
+               if ((dest->addr.ip == daddr)
                    && (dest->port == dport)
                    && ((dest->protocol == protocol) ||
                        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
         */
        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 */
                        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, "
                          "dest->refcnt=%d\n",
                          dest->vfwmark,
-                         NIPQUAD(dest->addr), ntohs(dest->port),
+                         NIPQUAD(dest->addr.ip), ntohs(dest->port),
                          atomic_read(&dest->refcnt));
-               if (dest->addr == daddr &&
+               if (dest->addr.ip == daddr &&
                    dest->port == dport &&
                    dest->vfwmark == svc->fwmark &&
                    dest->protocol == svc->protocol &&
                    (svc->fwmark ||
-                    (dest->vaddr == svc->addr &&
+                    (dest->vaddr.ip == svc->addr.ip &&
                      dest->vport == svc->port))) {
                        /* HIT */
                        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 "
                                  "from trash\n",
                                  dest->vfwmark,
-                                 NIPQUAD(dest->addr), ntohs(dest->port));
+                                 NIPQUAD(dest->addr.ip), ntohs(dest->port));
                        list_del(&dest->n_list);
                        ip_vs_dst_reset(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->vaddr = svc->addr;
+       dest->vaddr.ip = svc->addr.ip;
        dest->vport = svc->port;
        dest->vfwmark = svc->fwmark;
-       dest->addr = udest->addr;
+       dest->addr.ip = udest->addr;
        dest->port = udest->port;
 
        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),
                          atomic_read(&dest->refcnt),
                          dest->vfwmark,
-                         NIPQUAD(dest->vaddr),
+                         NIPQUAD(dest->vaddr.ip),
                          ntohs(dest->vport));
                __ip_vs_update_dest(svc, dest, udest);
 
@@ -993,7 +994,7 @@ static void __ip_vs_del_dest(struct ip_vs_dest *dest)
        } else {
                IP_VS_DBG(3, "Moving dest %u.%u.%u.%u:%u into trash, "
                          "dest->refcnt=%d\n",
-                         NIPQUAD(dest->addr), ntohs(dest->port),
+                         NIPQUAD(dest->addr.ip), ntohs(dest->port),
                          atomic_read(&dest->refcnt));
                list_add(&dest->n_list, &ip_vs_dest_trash);
                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);
 
        svc->protocol = u->protocol;
-       svc->addr = u->addr;
+       svc->addr.ip = u->addr;
        svc->port = u->port;
        svc->fwmark = u->fwmark;
        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)
                        seq_printf(seq, "%s  %08X:%04X %s ",
                                   ip_vs_proto_name(svc->protocol),
-                                  ntohl(svc->addr),
+                                  ntohl(svc->addr.ip),
                                   ntohs(svc->port),
                                   svc->scheduler->name);
                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) {
                        seq_printf(seq,
                                   "  -> %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)),
                                   atomic_read(&dest->weight),
                                   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)
 {
        dst->protocol = src->protocol;
-       dst->addr = src->addr;
+       dst->addr = src->addr.ip;
        dst->port = src->port;
        dst->fwmark = src->fwmark;
        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)
                                break;
 
-                       entry.addr = dest->addr;
+                       entry.addr = dest->addr.ip;
                        entry.port = dest->port;
                        entry.conn_flags = atomic_read(&dest->conn_flags);
                        entry.weight = atomic_read(&dest->weight);
index fa66824d264f6b21c84105cc00c3cb0c01e57534..9f9d795dbd7745299acbe6e36db4ba90c0a420e6 100644 (file)
@@ -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 "
                  "--> server %u.%u.%u.%u:%d\n",
                  NIPQUAD(iph->daddr),
-                 NIPQUAD(dest->addr),
+                 NIPQUAD(dest->addr.ip),
                  ntohs(dest->port));
 
        return dest;
index c1c758e4f733082917f7f2030242763efcce619a..bfe5d7050a58d9fbc18cc5a610939a17c6ac1fb2 100644 (file)
@@ -172,17 +172,17 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
 
                IP_VS_DBG(7, "PASV response (%u.%u.%u.%u:%d) -> "
                          "%u.%u.%u.%u:%d detected\n",
-                         NIPQUAD(from), ntohs(port), NIPQUAD(cp->caddr), 0);
+                         NIPQUAD(from), ntohs(port), NIPQUAD(cp->caddr.ip), 0);
 
                /*
                 * Now update or create an connection entry for it
                 */
                n_cp = ip_vs_conn_out_get(iph->protocol, from, port,
-                                         cp->caddr, 0);
+                                         cp->caddr.ip, 0);
                if (!n_cp) {
                        n_cp = ip_vs_conn_new(IPPROTO_TCP,
-                                             cp->caddr, 0,
-                                             cp->vaddr, port,
+                                             cp->caddr.ip, 0,
+                                             cp->vaddr.ip, port,
                                              from, port,
                                              IP_VS_CONN_F_NO_CPORT,
                                              cp->dest);
@@ -196,7 +196,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
                /*
                 * Replace the old passive address with the new one
                 */
-               from = n_cp->vaddr;
+               from = n_cp->vaddr.ip;
                port = n_cp->vport;
                sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from),
                        (ntohs(port)>>8)&255, ntohs(port)&255);
@@ -306,16 +306,16 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
         */
        IP_VS_DBG(7, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n",
                  ip_vs_proto_name(iph->protocol),
-                 NIPQUAD(to), ntohs(port), NIPQUAD(cp->vaddr), 0);
+                 NIPQUAD(to), ntohs(port), NIPQUAD(cp->vaddr.ip), 0);
 
        n_cp = ip_vs_conn_in_get(iph->protocol,
                                 to, port,
-                                cp->vaddr, htons(ntohs(cp->vport)-1));
+                                cp->vaddr.ip, htons(ntohs(cp->vport)-1));
        if (!n_cp) {
                n_cp = ip_vs_conn_new(IPPROTO_TCP,
                                      to, port,
-                                     cp->vaddr, htons(ntohs(cp->vport)-1),
-                                     cp->daddr, htons(ntohs(cp->dport)-1),
+                                     cp->vaddr.ip, htons(ntohs(cp->vport)-1),
+                                     cp->daddr.ip, htons(ntohs(cp->dport)-1),
                                      0,
                                      cp->dest);
                if (!n_cp)
index d2a43aa3fe4ceecc223da4784cb6d6bea766cd9c..69309edc0c4aa4d62d982bd24bdbd3b6f3620bf8 100644 (file)
@@ -422,7 +422,7 @@ __ip_vs_lblc_schedule(struct ip_vs_service *svc, struct iphdr *iph)
 
        IP_VS_DBG(6, "LBLC: server %d.%d.%d.%d:%d "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
@@ -506,7 +506,7 @@ out:
        IP_VS_DBG(6, "LBLC: destination IP address %u.%u.%u.%u "
                  "--> server %u.%u.%u.%u:%d\n",
                  NIPQUAD(iph->daddr),
-                 NIPQUAD(dest->addr),
+                 NIPQUAD(dest->addr.ip),
                  ntohs(dest->port));
 
        return dest;
index 375a1ffb6b65963f00e32c95f670160602a8b028..51c746e20832483224a2d10654b4c377319d2c35 100644 (file)
@@ -204,7 +204,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_min(struct ip_vs_dest_set *set)
 
        IP_VS_DBG(6, "ip_vs_dest_set_min: server %d.%d.%d.%d:%d "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
@@ -250,7 +250,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
 
        IP_VS_DBG(6, "ip_vs_dest_set_max: server %d.%d.%d.%d:%d "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(most->addr), ntohs(most->port),
+                 NIPQUAD(most->addr.ip), ntohs(most->port),
                  atomic_read(&most->activeconns),
                  atomic_read(&most->refcnt),
                  atomic_read(&most->weight), moh);
@@ -598,7 +598,7 @@ __ip_vs_lblcr_schedule(struct ip_vs_service *svc, struct iphdr *iph)
 
        IP_VS_DBG(6, "LBLCR: server %d.%d.%d.%d:%d "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
@@ -706,7 +706,7 @@ out:
        IP_VS_DBG(6, "LBLCR: destination IP address %u.%u.%u.%u "
                  "--> server %u.%u.%u.%u:%d\n",
                  NIPQUAD(iph->daddr),
-                 NIPQUAD(dest->addr),
+                 NIPQUAD(dest->addr.ip),
                  ntohs(dest->port));
 
        return dest;
index 2c3de1b635189274e4a132e2e3fe6074f0cdb825..551d293347f8057df92c8a07e5cb26de9c147d21 100644 (file)
@@ -68,7 +68,7 @@ ip_vs_lc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 
        if (least)
        IP_VS_DBG(6, "LC: server %u.%u.%u.%u:%u activeconns %d inactconns %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->inactconns));
 
index 5330d5a2de143a1d8be58af0fc1be37e6c1229a8..aa0e32ad3486904bcb1ebb37da9fccef677d2d0f 100644 (file)
@@ -101,7 +101,7 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
   out:
        IP_VS_DBG(6, "NQ: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
index d0ea467986a017e9ea45779aa7b0b75ff77b6a4b..15860e1441b08fd41d96a413015aa59633f29ae7 100644 (file)
@@ -147,7 +147,7 @@ tcp_snat_handler(struct sk_buff *skb,
        /* Adjust TCP checksums */
        if (!cp->app) {
                /* Only port and addr are changed, do fast csum update */
-               tcp_fast_csum_update(tcph, cp->daddr, cp->vaddr,
+               tcp_fast_csum_update(tcph, cp->daddr.ip, cp->vaddr.ip,
                                     cp->dport, cp->vport);
                if (skb->ip_summed == CHECKSUM_COMPLETE)
                        skb->ip_summed = CHECKSUM_NONE;
@@ -155,7 +155,7 @@ tcp_snat_handler(struct sk_buff *skb,
                /* full checksum calculation */
                tcph->check = 0;
                skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
-               tcph->check = csum_tcpudp_magic(cp->vaddr, cp->caddr,
+               tcph->check = csum_tcpudp_magic(cp->vaddr.ip, cp->caddr.ip,
                                                skb->len - tcphoff,
                                                cp->protocol, skb->csum);
                IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
@@ -198,7 +198,7 @@ tcp_dnat_handler(struct sk_buff *skb,
         */
        if (!cp->app) {
                /* Only port and addr are changed, do fast csum update */
-               tcp_fast_csum_update(tcph, cp->vaddr, cp->daddr,
+               tcp_fast_csum_update(tcph, cp->vaddr.ip, cp->daddr.ip,
                                     cp->vport, cp->dport);
                if (skb->ip_summed == CHECKSUM_COMPLETE)
                        skb->ip_summed = CHECKSUM_NONE;
@@ -206,7 +206,7 @@ tcp_dnat_handler(struct sk_buff *skb,
                /* full checksum calculation */
                tcph->check = 0;
                skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
-               tcph->check = csum_tcpudp_magic(cp->caddr, cp->daddr,
+               tcph->check = csum_tcpudp_magic(cp->caddr.ip, cp->daddr.ip,
                                                skb->len - tcphoff,
                                                cp->protocol, skb->csum);
                skb->ip_summed = CHECKSUM_UNNECESSARY;
@@ -427,8 +427,8 @@ set_tcp_state(struct ip_vs_protocol *pp, struct ip_vs_conn *cp,
                          th->fin? 'F' : '.',
                          th->ack? 'A' : '.',
                          th->rst? 'R' : '.',
-                         NIPQUAD(cp->daddr), ntohs(cp->dport),
-                         NIPQUAD(cp->caddr), ntohs(cp->cport),
+                         NIPQUAD(cp->daddr.ip), ntohs(cp->dport),
+                         NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
                          tcp_state_name(cp->state),
                          tcp_state_name(new_state),
                          atomic_read(&cp->refcnt));
@@ -549,8 +549,8 @@ tcp_app_conn_bind(struct ip_vs_conn *cp)
                        IP_VS_DBG(9, "%s: Binding conn %u.%u.%u.%u:%u->"
                                  "%u.%u.%u.%u:%u to app %s on port %u\n",
                                  __func__,
-                                 NIPQUAD(cp->caddr), ntohs(cp->cport),
-                                 NIPQUAD(cp->vaddr), ntohs(cp->vport),
+                                 NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
+                                 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
                                  inc->name, ntohs(inc->port));
                        cp->app = inc;
                        if (inc->init_conn)
index c6be5d56823f660564ce70727f32abb7d5046bd9..8dfad5db8295291a1a92073f9dadc9d58658692f 100644 (file)
@@ -158,7 +158,7 @@ udp_snat_handler(struct sk_buff *skb,
         */
        if (!cp->app && (udph->check != 0)) {
                /* Only port and addr are changed, do fast csum update */
-               udp_fast_csum_update(udph, cp->daddr, cp->vaddr,
+               udp_fast_csum_update(udph, cp->daddr.ip, cp->vaddr.ip,
                                     cp->dport, cp->vport);
                if (skb->ip_summed == CHECKSUM_COMPLETE)
                        skb->ip_summed = CHECKSUM_NONE;
@@ -166,7 +166,7 @@ udp_snat_handler(struct sk_buff *skb,
                /* full checksum calculation */
                udph->check = 0;
                skb->csum = skb_checksum(skb, udphoff, skb->len - udphoff, 0);
-               udph->check = csum_tcpudp_magic(cp->vaddr, cp->caddr,
+               udph->check = csum_tcpudp_magic(cp->vaddr.ip, cp->caddr.ip,
                                                skb->len - udphoff,
                                                cp->protocol, skb->csum);
                if (udph->check == 0)
@@ -211,7 +211,7 @@ udp_dnat_handler(struct sk_buff *skb,
         */
        if (!cp->app && (udph->check != 0)) {
                /* Only port and addr are changed, do fast csum update */
-               udp_fast_csum_update(udph, cp->vaddr, cp->daddr,
+               udp_fast_csum_update(udph, cp->vaddr.ip, cp->daddr.ip,
                                     cp->vport, cp->dport);
                if (skb->ip_summed == CHECKSUM_COMPLETE)
                        skb->ip_summed = CHECKSUM_NONE;
@@ -219,7 +219,7 @@ udp_dnat_handler(struct sk_buff *skb,
                /* full checksum calculation */
                udph->check = 0;
                skb->csum = skb_checksum(skb, udphoff, skb->len - udphoff, 0);
-               udph->check = csum_tcpudp_magic(cp->caddr, cp->daddr,
+               udph->check = csum_tcpudp_magic(cp->caddr.ip, cp->daddr.ip,
                                                skb->len - udphoff,
                                                cp->protocol, skb->csum);
                if (udph->check == 0)
@@ -343,8 +343,8 @@ static int udp_app_conn_bind(struct ip_vs_conn *cp)
                        IP_VS_DBG(9, "%s: Binding conn %u.%u.%u.%u:%u->"
                                  "%u.%u.%u.%u:%u to app %s on port %u\n",
                                  __func__,
-                                 NIPQUAD(cp->caddr), ntohs(cp->cport),
-                                 NIPQUAD(cp->vaddr), ntohs(cp->vport),
+                                 NIPQUAD(cp->caddr.ip), ntohs(cp->cport),
+                                 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport),
                                  inc->name, ntohs(inc->port));
                        cp->app = inc;
                        if (inc->init_conn)
index f749291175346e66eaf9adfcdc69f7a4a978bf54..27f0b624283dd6fab3cfc1687f43b8e5c8c0bc5b 100644 (file)
@@ -76,7 +76,7 @@ ip_vs_rr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        write_unlock(&svc->sched_lock);
        IP_VS_DBG(6, "RR: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d\n",
-                 NIPQUAD(dest->addr), ntohs(dest->port),
+                 NIPQUAD(dest->addr.ip), ntohs(dest->port),
                  atomic_read(&dest->activeconns),
                  atomic_read(&dest->refcnt), atomic_read(&dest->weight));
 
index 53f73bea66ced49e98d7590dc586423e3cb2b048..38b574b2fdf0dbd2e74e74461c22be1bbe3f1af1 100644 (file)
@@ -103,7 +103,7 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 
        IP_VS_DBG(6, "SED: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
index 7b979e22805647356ce0237d23ebb5c9f79ed4d4..c9e54e2ec29096519e965764e29bd54da9f24e67 100644 (file)
@@ -215,7 +215,7 @@ ip_vs_sh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        IP_VS_DBG(6, "SH: source IP address %u.%u.%u.%u "
                  "--> server %u.%u.%u.%u:%d\n",
                  NIPQUAD(iph->saddr),
-                 NIPQUAD(dest->addr),
+                 NIPQUAD(dest->addr.ip),
                  ntohs(dest->port));
 
        return dest;
index a652da2c3200c55e0c30e5d5c99315e95361db5f..2cf47b2e1669c8ad39b490586d6088b2a7cc8572 100644 (file)
@@ -256,9 +256,9 @@ void ip_vs_sync_conn(struct ip_vs_conn *cp)
        s->cport = cp->cport;
        s->vport = cp->vport;
        s->dport = cp->dport;
-       s->caddr = cp->caddr;
-       s->vaddr = cp->vaddr;
-       s->daddr = cp->daddr;
+       s->caddr = cp->caddr.ip;
+       s->vaddr = cp->vaddr.ip;
+       s->daddr = cp->daddr.ip;
        s->flags = htons(cp->flags & ~IP_VS_CONN_F_HASHED);
        s->state = htons(cp->state);
        if (cp->flags & IP_VS_CONN_F_SEQ_MASK) {
index df7ad8d74766fc679d63a42c0a0b76da31cba3dc..09fd993040f5cf6d616ef12ca9f4e5271d13d622 100644 (file)
@@ -91,7 +91,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 
        IP_VS_DBG(6, "WLC: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d overhead %d\n",
-                 NIPQUAD(least->addr), ntohs(least->port),
+                 NIPQUAD(least->addr.ip), ntohs(least->port),
                  atomic_read(&least->activeconns),
                  atomic_read(&least->refcnt),
                  atomic_read(&least->weight), loh);
index 0d86a79b87b5d5c5aed7e860c38d941f626c435d..19c49b234f3529497e1c9145f5c080421cc7681c 100644 (file)
@@ -197,7 +197,7 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 
        IP_VS_DBG(6, "WRR: server %u.%u.%u.%u:%u "
                  "activeconns %d refcnt %d weight %d\n",
-                 NIPQUAD(dest->addr), ntohs(dest->port),
+                 NIPQUAD(dest->addr.ip), ntohs(dest->port),
                  atomic_read(&dest->activeconns),
                  atomic_read(&dest->refcnt),
                  atomic_read(&dest->weight));
index 9892d4aca42e3d4e663490abfcd564a602fe4f95..88199c9f2d31ab011610ca3a6ec5c718fbb18bbc 100644 (file)
@@ -71,7 +71,7 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
                                .oif = 0,
                                .nl_u = {
                                        .ip4_u = {
-                                               .daddr = dest->addr,
+                                               .daddr = dest->addr.ip,
                                                .saddr = 0,
                                                .tos = rtos, } },
                        };
@@ -80,12 +80,12 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
                                spin_unlock(&dest->dst_lock);
                                IP_VS_DBG_RL("ip_route_output error, "
                                             "dest: %u.%u.%u.%u\n",
-                                            NIPQUAD(dest->addr));
+                                            NIPQUAD(dest->addr.ip));
                                return NULL;
                        }
                        __ip_vs_dst_set(dest, rtos, dst_clone(&rt->u.dst));
                        IP_VS_DBG(10, "new dst %u.%u.%u.%u, refcnt=%d, rtos=%X\n",
-                                 NIPQUAD(dest->addr),
+                                 NIPQUAD(dest->addr.ip),
                                  atomic_read(&rt->u.dst.__refcnt), rtos);
                }
                spin_unlock(&dest->dst_lock);
@@ -94,14 +94,14 @@ __ip_vs_get_out_rt(struct ip_vs_conn *cp, u32 rtos)
                        .oif = 0,
                        .nl_u = {
                                .ip4_u = {
-                                       .daddr = cp->daddr,
+                                       .daddr = cp->daddr.ip,
                                        .saddr = 0,
                                        .tos = rtos, } },
                };
 
                if (ip_route_output_key(&init_net, &rt, &fl)) {
                        IP_VS_DBG_RL("ip_route_output error, dest: "
-                                    "%u.%u.%u.%u\n", NIPQUAD(cp->daddr));
+                                    "%u.%u.%u.%u\n", NIPQUAD(cp->daddr.ip));
                        return NULL;
                }
        }
@@ -264,7 +264,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
        /* mangle the packet */
        if (pp->dnat_handler && !pp->dnat_handler(skb, pp, cp))
                goto tx_error;
-       ip_hdr(skb)->daddr = cp->daddr;
+       ip_hdr(skb)->daddr = cp->daddr.ip;
        ip_send_check(ip_hdr(skb));
 
        IP_VS_DBG_PKT(10, pp, skb, 0, "After DNAT");