struct ctdb_kill_tcp *killtcp;
};
+/* this function is used to create a key to represent this socketpair
+ in the killtcp tree.
+ this key is used to insert and lookup matching socketpairs that are
+ to be tickled and RST
+*/
+#define KILLTCP_KEYLEN 4
+static uint32_t *killtcp_key(struct sockaddr_in *src, struct sockaddr_in *dst)
+{
+ static uint32_t key[KILLTCP_KEYLEN];
+
+ key[0] = dst->sin_addr.s_addr;
+ key[1] = src->sin_addr.s_addr;
+ key[2] = dst->sin_port;
+ key[3] = src->sin_port;
+
+ return key;
+}
/*
called when we get a read event on the raw socket
struct ctdb_killtcp_con *con;
struct sockaddr_in src, dst;
uint32_t ack_seq, seq;
- uint32_t key[4];
if (!(flags & EVENT_FD_READ)) {
return;
/* check if we have this guy in our list of connections
to kill
*/
- key[0] = dst.sin_addr.s_addr;
- key[1] = src.sin_addr.s_addr;
- key[2] = dst.sin_port;
- key[3] = src.sin_port;
- con = trbt_lookuparray32(killtcp->connections, 4, key);
+ con = trbt_lookuparray32(killtcp->connections,
+ KILLTCP_KEYLEN, killtcp_key(&src, &dst));
if (con == NULL) {
/* no this was some other packet we can just ignore */
return;
/* loop over all connections sending tickle ACKs */
- trbt_traversearray32(killtcp->connections, 4, tickle_connection_traverse, killtcp);
+ trbt_traversearray32(killtcp->connections, KILLTCP_KEYLEN, tickle_connection_traverse, killtcp);
/* If there are no more connections to kill we can remove the
{
struct ctdb_kill_tcp *killtcp = ctdb->killtcp;
struct ctdb_killtcp_con *con;
- uint32_t key[4];
/* If this is the first connection to kill we must allocate
a new structure
con->killtcp = killtcp;
- key[0] = con->src.sin_addr.s_addr;
- key[1] = con->dst.sin_addr.s_addr;
- key[2] = con->src.sin_port;
- key[3] = con->dst.sin_port;
- trbt_insertarray32_callback(killtcp->connections, 4, key, add_killtcp_callback, con);
-
+ trbt_insertarray32_callback(killtcp->connections,
+ KILLTCP_KEYLEN, killtcp_key(&con->dst, &con->src),
+ add_killtcp_callback, con);
/*
If we dont have a socket to send from yet we must create it