From 70376bb5fe96b40392ba9297195150ff4fe8a94d Mon Sep 17 00:00:00 2001 From: Sven Wegener Date: Wed, 16 Jul 2008 11:13:43 +0000 Subject: [PATCH] --- yaml --- r: 103551 b: refs/heads/master c: e6dd731c75cba986a485924f908e6e05b088ea9e h: refs/heads/master i: 103549: e39216d2189f6a9dc92cf4be10e39def5c1cbf03 103547: 5fc15621fa0181a020bb4360787a245c798cfbea 103543: d683d06323158e9d05dcb171cd21f3999899b84e 103535: 6304f318656a616f76f91ae27c73622669309fb2 103519: d32b69c596e16ba21aab5c3af5b693216b938da4 103487: 010bb8eea836ed0f3240a79634edea0264d5859d 103423: 088dc7586fbfbea8d144e0fec084998e251b670f v: v3 --- [refs] | 2 +- trunk/net/ipv4/ipvs/ip_vs_sync.c | 46 +++++++++++++++++++------------- 2 files changed, 28 insertions(+), 20 deletions(-) diff --git a/[refs] b/[refs] index bee639a62a9f..5a8fe3a65f20 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: d56400504a40a4aa197af629300d76544169e821 +refs/heads/master: e6dd731c75cba986a485924f908e6e05b088ea9e diff --git a/trunk/net/ipv4/ipvs/ip_vs_sync.c b/trunk/net/ipv4/ipvs/ip_vs_sync.c index 8c900dfe832d..60b96823c9ae 100644 --- a/trunk/net/ipv4/ipvs/ip_vs_sync.c +++ b/trunk/net/ipv4/ipvs/ip_vs_sync.c @@ -27,6 +27,7 @@ #include #include /* for ip_mc_join_group */ #include +#include #include #include @@ -576,14 +577,17 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname) static struct socket * make_send_sock(void) { struct socket *sock; + int result; /* First create a socket */ - if (sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock) < 0) { + result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); + if (result < 0) { IP_VS_ERR("Error during creation of socket; terminating\n"); - return NULL; + return ERR_PTR(result); } - if (set_mcast_if(sock->sk, ip_vs_master_mcast_ifn) < 0) { + result = set_mcast_if(sock->sk, ip_vs_master_mcast_ifn); + if (result < 0) { IP_VS_ERR("Error setting outbound mcast interface\n"); goto error; } @@ -591,14 +595,15 @@ static struct socket * make_send_sock(void) set_mcast_loop(sock->sk, 0); set_mcast_ttl(sock->sk, 1); - if (bind_mcastif_addr(sock, ip_vs_master_mcast_ifn) < 0) { + result = bind_mcastif_addr(sock, ip_vs_master_mcast_ifn); + if (result < 0) { IP_VS_ERR("Error binding address of the mcast interface\n"); goto error; } - if (sock->ops->connect(sock, - (struct sockaddr*)&mcast_addr, - sizeof(struct sockaddr), 0) < 0) { + result = sock->ops->connect(sock, (struct sockaddr *) &mcast_addr, + sizeof(struct sockaddr), 0); + if (result < 0) { IP_VS_ERR("Error connecting to the multicast addr\n"); goto error; } @@ -607,7 +612,7 @@ static struct socket * make_send_sock(void) error: sock_release(sock); - return NULL; + return ERR_PTR(result); } @@ -617,27 +622,30 @@ static struct socket * make_send_sock(void) static struct socket * make_receive_sock(void) { struct socket *sock; + int result; /* First create a socket */ - if (sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock) < 0) { + result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock); + if (result < 0) { IP_VS_ERR("Error during creation of socket; terminating\n"); - return NULL; + return ERR_PTR(result); } /* it is equivalent to the REUSEADDR option in user-space */ sock->sk->sk_reuse = 1; - if (sock->ops->bind(sock, - (struct sockaddr*)&mcast_addr, - sizeof(struct sockaddr)) < 0) { + result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr, + sizeof(struct sockaddr)); + if (result < 0) { IP_VS_ERR("Error binding to the multicast addr\n"); goto error; } /* join the multicast group */ - if (join_mcast_group(sock->sk, - (struct in_addr*)&mcast_addr.sin_addr, - ip_vs_backup_mcast_ifn) < 0) { + result = join_mcast_group(sock->sk, + (struct in_addr *) &mcast_addr.sin_addr, + ip_vs_backup_mcast_ifn); + if (result < 0) { IP_VS_ERR("Error joining to the multicast group\n"); goto error; } @@ -646,7 +654,7 @@ static struct socket * make_receive_sock(void) error: sock_release(sock); - return NULL; + return ERR_PTR(result); } @@ -719,7 +727,7 @@ static void sync_master_loop(void) /* create the sending multicast socket */ sock = make_send_sock(); - if (!sock) + if (IS_ERR(sock)) return; IP_VS_INFO("sync thread started: state = MASTER, mcast_ifn = %s, " @@ -772,7 +780,7 @@ static void sync_backup_loop(void) /* create the receiving multicast socket */ sock = make_receive_sock(); - if (!sock) + if (IS_ERR(sock)) goto out; IP_VS_INFO("sync thread started: state = BACKUP, mcast_ifn = %s, "