aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorSven Wegener <sven.wegener@stealer.net>2008-07-16 07:13:43 -0400
committerSven Wegener <sven.wegener@stealer.net>2008-07-16 18:33:19 -0400
commite6dd731c75cba986a485924f908e6e05b088ea9e (patch)
treed9d88b0ec6ded9da8a4e85d129736720ffef8567 /net/ipv4
parentd56400504a40a4aa197af629300d76544169e821 (diff)
ipvs: Use ERR_PTR for returning errors from make_receive_sock() and make_send_sock()
The additional information we now return to the caller is currently not used, but will be used to return errors to user space. Signed-off-by: Sven Wegener <sven.wegener@stealer.net> Acked-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c46
1 files changed, 27 insertions, 19 deletions
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 8c900dfe832d..60b96823c9ae 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -27,6 +27,7 @@
27#include <linux/in.h> 27#include <linux/in.h>
28#include <linux/igmp.h> /* for ip_mc_join_group */ 28#include <linux/igmp.h> /* for ip_mc_join_group */
29#include <linux/udp.h> 29#include <linux/udp.h>
30#include <linux/err.h>
30 31
31#include <net/ip.h> 32#include <net/ip.h>
32#include <net/sock.h> 33#include <net/sock.h>
@@ -576,14 +577,17 @@ static int bind_mcastif_addr(struct socket *sock, char *ifname)
576static struct socket * make_send_sock(void) 577static struct socket * make_send_sock(void)
577{ 578{
578 struct socket *sock; 579 struct socket *sock;
580 int result;
579 581
580 /* First create a socket */ 582 /* First create a socket */
581 if (sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock) < 0) { 583 result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
584 if (result < 0) {
582 IP_VS_ERR("Error during creation of socket; terminating\n"); 585 IP_VS_ERR("Error during creation of socket; terminating\n");
583 return NULL; 586 return ERR_PTR(result);
584 } 587 }
585 588
586 if (set_mcast_if(sock->sk, ip_vs_master_mcast_ifn) < 0) { 589 result = set_mcast_if(sock->sk, ip_vs_master_mcast_ifn);
590 if (result < 0) {
587 IP_VS_ERR("Error setting outbound mcast interface\n"); 591 IP_VS_ERR("Error setting outbound mcast interface\n");
588 goto error; 592 goto error;
589 } 593 }
@@ -591,14 +595,15 @@ static struct socket * make_send_sock(void)
591 set_mcast_loop(sock->sk, 0); 595 set_mcast_loop(sock->sk, 0);
592 set_mcast_ttl(sock->sk, 1); 596 set_mcast_ttl(sock->sk, 1);
593 597
594 if (bind_mcastif_addr(sock, ip_vs_master_mcast_ifn) < 0) { 598 result = bind_mcastif_addr(sock, ip_vs_master_mcast_ifn);
599 if (result < 0) {
595 IP_VS_ERR("Error binding address of the mcast interface\n"); 600 IP_VS_ERR("Error binding address of the mcast interface\n");
596 goto error; 601 goto error;
597 } 602 }
598 603
599 if (sock->ops->connect(sock, 604 result = sock->ops->connect(sock, (struct sockaddr *) &mcast_addr,
600 (struct sockaddr*)&mcast_addr, 605 sizeof(struct sockaddr), 0);
601 sizeof(struct sockaddr), 0) < 0) { 606 if (result < 0) {
602 IP_VS_ERR("Error connecting to the multicast addr\n"); 607 IP_VS_ERR("Error connecting to the multicast addr\n");
603 goto error; 608 goto error;
604 } 609 }
@@ -607,7 +612,7 @@ static struct socket * make_send_sock(void)
607 612
608 error: 613 error:
609 sock_release(sock); 614 sock_release(sock);
610 return NULL; 615 return ERR_PTR(result);
611} 616}
612 617
613 618
@@ -617,27 +622,30 @@ static struct socket * make_send_sock(void)
617static struct socket * make_receive_sock(void) 622static struct socket * make_receive_sock(void)
618{ 623{
619 struct socket *sock; 624 struct socket *sock;
625 int result;
620 626
621 /* First create a socket */ 627 /* First create a socket */
622 if (sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock) < 0) { 628 result = sock_create_kern(PF_INET, SOCK_DGRAM, IPPROTO_UDP, &sock);
629 if (result < 0) {
623 IP_VS_ERR("Error during creation of socket; terminating\n"); 630 IP_VS_ERR("Error during creation of socket; terminating\n");
624 return NULL; 631 return ERR_PTR(result);
625 } 632 }
626 633
627 /* it is equivalent to the REUSEADDR option in user-space */ 634 /* it is equivalent to the REUSEADDR option in user-space */
628 sock->sk->sk_reuse = 1; 635 sock->sk->sk_reuse = 1;
629 636
630 if (sock->ops->bind(sock, 637 result = sock->ops->bind(sock, (struct sockaddr *) &mcast_addr,
631 (struct sockaddr*)&mcast_addr, 638 sizeof(struct sockaddr));
632 sizeof(struct sockaddr)) < 0) { 639 if (result < 0) {
633 IP_VS_ERR("Error binding to the multicast addr\n"); 640 IP_VS_ERR("Error binding to the multicast addr\n");
634 goto error; 641 goto error;
635 } 642 }
636 643
637 /* join the multicast group */ 644 /* join the multicast group */
638 if (join_mcast_group(sock->sk, 645 result = join_mcast_group(sock->sk,
639 (struct in_addr*)&mcast_addr.sin_addr, 646 (struct in_addr *) &mcast_addr.sin_addr,
640 ip_vs_backup_mcast_ifn) < 0) { 647 ip_vs_backup_mcast_ifn);
648 if (result < 0) {
641 IP_VS_ERR("Error joining to the multicast group\n"); 649 IP_VS_ERR("Error joining to the multicast group\n");
642 goto error; 650 goto error;
643 } 651 }
@@ -646,7 +654,7 @@ static struct socket * make_receive_sock(void)
646 654
647 error: 655 error:
648 sock_release(sock); 656 sock_release(sock);
649 return NULL; 657 return ERR_PTR(result);
650} 658}
651 659
652 660
@@ -719,7 +727,7 @@ static void sync_master_loop(void)
719 727
720 /* create the sending multicast socket */ 728 /* create the sending multicast socket */
721 sock = make_send_sock(); 729 sock = make_send_sock();
722 if (!sock) 730 if (IS_ERR(sock))
723 return; 731 return;
724 732
725 IP_VS_INFO("sync thread started: state = MASTER, mcast_ifn = %s, " 733 IP_VS_INFO("sync thread started: state = MASTER, mcast_ifn = %s, "
@@ -772,7 +780,7 @@ static void sync_backup_loop(void)
772 780
773 /* create the receiving multicast socket */ 781 /* create the receiving multicast socket */
774 sock = make_receive_sock(); 782 sock = make_receive_sock();
775 if (!sock) 783 if (IS_ERR(sock))
776 goto out; 784 goto out;
777 785
778 IP_VS_INFO("sync thread started: state = BACKUP, mcast_ifn = %s, " 786 IP_VS_INFO("sync thread started: state = BACKUP, mcast_ifn = %s, "