ctdb-daemon: Remove older data structure that supports only IPv4 addresses
authorAmitay Isaacs <amitay@gmail.com>
Mon, 23 Mar 2015 06:32:34 +0000 (17:32 +1100)
committerJeremy Allison <jra@samba.org>
Mon, 11 May 2015 23:32:11 +0000 (01:32 +0200)
Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
ctdb/include/ctdb_client.h
ctdb/server/ctdb_control.c
ctdb/server/ctdb_takeover.c
source3/lib/ctdbd_conn.c

index 57f491742d6083c737776767de3430545c999f13..0a61afcb7246f21e18bde71c286cd5ddc704c3e9 100644 (file)
@@ -470,17 +470,6 @@ struct ctdb_uptime {
        struct timeval last_recovery_finished;
 };
 
-/*
-  struct for tcp_client control
-  this is an ipv4 only version of this structure used by samba
-  samba will later be migrated over to use the
-  ctdb_control_tcp_addr structure instead
- */
-struct ctdb_control_tcp {
-       struct sockaddr_in src;  /* samba uses this */
-       struct sockaddr_in dest; /* samba uses this */
-};
-/* new style structure */
 struct ctdb_control_tcp_addr {
        ctdb_sock_addr src;
        ctdb_sock_addr dest;
index dafdc428bbb7ff49642d48785199051701871e7e..f3f70a38de54ad25b09e56bf0b62669ca6d39190 100644 (file)
@@ -378,7 +378,8 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(0);
                return ctdb_control_get_public_ips(ctdb, c, outdata);
 
-       case CTDB_CONTROL_TCP_CLIENT: 
+       case CTDB_CONTROL_TCP_CLIENT:
+               CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_tcp_addr));
                return ctdb_control_tcp_client(ctdb, client_id, indata);
 
        case CTDB_CONTROL_STARTUP: 
index 556b2479bf7290887a7716447afd6dd2e627ad2e..31e1b827ccaead881a08f7b685e319ec4f226b8c 100644 (file)
@@ -2869,15 +2869,11 @@ static int ctdb_client_ip_destructor(struct ctdb_client_ip *ip)
 /*
   called by a client to inform us of a TCP connection that it is managing
   that should tickled with an ACK when IP takeover is done
-  we handle both the old ipv4 style of packets as well as the new ipv4/6
-  pdus.
  */
 int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
                                TDB_DATA indata)
 {
        struct ctdb_client *client = ctdb_reqid_find(ctdb, client_id, struct ctdb_client);
-       struct ctdb_control_tcp *old_addr = NULL;
-       struct ctdb_control_tcp_addr new_addr;
        struct ctdb_control_tcp_addr *tcp_sock = NULL;
        struct ctdb_tcp_list *tcp;
        struct ctdb_tcp_connection t;
@@ -2892,26 +2888,7 @@ int32_t ctdb_control_tcp_client(struct ctdb_context *ctdb, uint32_t client_id,
                return 0;
        }
 
-       switch (indata.dsize) {
-       case sizeof(struct ctdb_control_tcp):
-               old_addr = (struct ctdb_control_tcp *)indata.dptr;
-               ZERO_STRUCT(new_addr);
-               tcp_sock = &new_addr;
-               tcp_sock->src.ip  = old_addr->src;
-               tcp_sock->dest.ip = old_addr->dest;
-               break;
-       case sizeof(struct ctdb_control_tcp_addr):
-               tcp_sock = (struct ctdb_control_tcp_addr *)indata.dptr;
-               break;
-       default:
-               DEBUG(DEBUG_ERR,(__location__ " Invalid data structure passed "
-                                "to ctdb_control_tcp_client. size was %d but "
-                                "only allowed sizes are %lu and %lu\n",
-                                (int)indata.dsize,
-                                (long unsigned)sizeof(struct ctdb_control_tcp),
-                                (long unsigned)sizeof(struct ctdb_control_tcp_addr)));
-               return -1;
-       }
+       tcp_sock = (struct ctdb_control_tcp_addr *)indata.dptr;
 
        addr = tcp_sock->src;
        ctdb_canonicalize_ip(&addr,  &tcp_sock->src);
index 85717dd0dccc4a03c0adce2deeaeaff2cd4836dc..748a99ffa74624e2775600bc2766ab39bdd2cf38 100644 (file)
@@ -1632,12 +1632,6 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
                                                       void *private_data),
                            void *private_data)
 {
-       /*
-        * we still use ctdb_control_tcp for ipv4
-        * because we want to work against older ctdb
-        * versions at runtime
-        */
-       struct ctdb_control_tcp p4;
        struct ctdb_control_tcp_addr p;
        TDB_DATA data;
        NTSTATUS status;
@@ -1654,10 +1648,10 @@ NTSTATUS ctdbd_register_ips(struct ctdbd_connection *conn,
 
        switch (client.ss_family) {
        case AF_INET:
-               memcpy(&p4.dest, &server, sizeof(p4.dest));
-               memcpy(&p4.src, &client, sizeof(p4.src));
-               data.dptr = (uint8_t *)&p4;
-               data.dsize = sizeof(p4);
+               memcpy(&p.dest.ip, &server, sizeof(p.dest.ip));
+               memcpy(&p.src.ip, &client, sizeof(p.src.ip));
+               data.dptr = (uint8_t *)&p;
+               data.dsize = sizeof(p);
                break;
        case AF_INET6:
                memcpy(&p.dest.ip6, &server, sizeof(p.dest.ip6));