Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 486186
Collapse All | Expand All

(-)file_not_specified_in_diff (-30 / +35 lines)
Line  Link Here
0
-- a/lib/plugins/HBcomm/ucast.c
0
++ b/lib/plugins/HBcomm/ucast.c
Lines 461-472 static int HB_make_send_sock(struct hb_m Link Here
461
	int sockfd;
461
	int sockfd;
462
	struct ip_private *ei;
462
	struct ip_private *ei;
463
	int tos;
463
	int tos;
464
#if defined(SO_BINDTODEVICE)
465
	struct ifreq i;
466
#endif
467
#if defined(SO_REUSEPORT)
468
	int i = 1;
469
#endif
470
464
471
	UCASTASSERT(mp);
465
	UCASTASSERT(mp);
472
	ei = (struct ip_private*)mp->pd;
466
	ei = (struct ip_private*)mp->pd;
Lines 494-499 static int HB_make_send_sock(struct hb_m Link Here
494
488
495
#if defined(SO_BINDTODEVICE)
489
#if defined(SO_BINDTODEVICE)
496
	{
490
	{
491
		struct ifreq i;
497
		/*
492
		/*
498
		 *  We want to send out this particular interface
493
		 *  We want to send out this particular interface
499
		 *
494
		 *
Lines 515-526 static int HB_make_send_sock(struct hb_m Link Here
515
#endif
510
#endif
516
#if defined(SO_REUSEPORT)
511
#if defined(SO_REUSEPORT)
517
	{
512
	{
513
		int one = 1;
518
		/* this is for OpenBSD to allow multiple *
514
		/* this is for OpenBSD to allow multiple *
519
		*  ucast connections, e.g. a more than   *
515
		*  ucast connections, e.g. a more than   *
520
		*  two node cluster 			 */
516
		*  two node cluster 			 */
521
517
522
		if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
518
		if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
523
				&i, sizeof(i)) == -1) {
519
				&one, sizeof(one)) == -1) {
524
			PILCallLog(LOG, PIL_CRIT,
520
			PILCallLog(LOG, PIL_CRIT,
525
			  "ucast: error setting option SO_REUSEPORT(w): %s", strerror(errno));
521
			  "ucast: error setting option SO_REUSEPORT(w): %s", strerror(errno));
526
			close(sockfd);
522
			close(sockfd);
Lines 548-554 static int HB_make_receive_sock(struct h Link Here
548
	int sockfd;
544
	int sockfd;
549
	int bindtries;
545
	int bindtries;
550
	int boundyet = 0;
546
	int boundyet = 0;
551
	int j;
547
	int one = 1;
552
548
553
	UCASTASSERT(mp);
549
	UCASTASSERT(mp);
554
	ei = (struct ip_private*)mp->pd;
550
	ei = (struct ip_private*)mp->pd;
Lines 563-584 static int HB_make_receive_sock(struct h Link Here
563
			strerror(errno));
559
			strerror(errno));
564
		return -1;
560
		return -1;
565
	}
561
	}
566
	/* 
562
	/*
567
 	 * Set SO_REUSEADDR on the server socket s. Variable j is used
563
	 * Set SO_REUSEADDR on the server socket s.
568
 	 * as a scratch varable.
564
	 * Below, also try to set SO_REUSEPORT,
569
 	 *
565
	 * if known and supported.
570
 	 * 16th February 2000
566
	 */
571
 	 * Added by Horms <horms@vergenet.net>
572
 	 * with thanks to Clinton Work <work@scripty.com>
573
 	 */
574
	j = 1;
575
	if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
567
	if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
576
			(void *)&j, sizeof j) < 0) {
568
			&one, sizeof(one)) < 0) {
577
		/* Ignore it.  It will almost always be OK anyway. */
569
		/* Ignore it.  It will almost always be OK anyway. */
578
		PILCallLog(LOG, PIL_CRIT,
570
		PILCallLog(LOG, PIL_WARN,
579
			"ucast: error setting socket option SO_REUSEADDR: %s",
571
			"ucast: error setting socket option SO_REUSEADDR: %s",
580
			strerror(errno));
572
			strerror(errno));
581
	}        
573
	} else
574
		PILCallLog(LOG, PIL_INFO, "ucast: set SO_REUSEADDR");
582
#if defined(SO_BINDTODEVICE)
575
#if defined(SO_BINDTODEVICE)
583
	{
576
	{
584
		/*
577
		/*
Lines 600-619 static int HB_make_receive_sock(struct h Link Here
600
	}
593
	}
601
#endif
594
#endif
602
#if defined(SO_REUSEPORT)
595
#if defined(SO_REUSEPORT)
603
	{
596
	/*
597
	 *  Needed for OpenBSD for more than two nodes in a ucast cluster
598
	 */
599
	if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
600
			&one, sizeof(one)) == -1) {
604
		/*
601
		/*
605
		 *  Needed for OpenBSD for more than two nodes in a ucast cluster
602
		 * Linux learned SO_REUSEPORT only with kernel 3.9,
603
		 * but some linux headers already define SO_REUSEPORT.
604
		 * Which will result in ENOPROTOOPT, "Protocol not available"
605
		 * on older kernels.
606
		 * Failure to set SO_REUSEPORT is NOT critical in general.
607
		 * It *may* be a problem on certain BSDs with more than
608
		 * two nodes all using ucast.
609
		 * Refusing to start because of failure to set SO_REUSEPORT is
610
		 * not helpful for the vast majority of the clusters out there.
606
		 */
611
		 */
607
		int i = 1;
612
		if (errno == ENOPROTOOPT) {
608
		if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEPORT,
613
			PILCallLog(LOG, PIL_WARN,
609
				&i, sizeof(i)) == -1) {
614
			  "ucast: error setting option SO_REUSEPORT: %s", strerror(errno));
615
		} else {
610
			PILCallLog(LOG, PIL_CRIT,
616
			PILCallLog(LOG, PIL_CRIT,
611
			  "ucast: error setting option SO_REUSEPORT(r) %s", strerror(errno));
617
			  "ucast: error setting option SO_REUSEPORT: %s", strerror(errno));
612
			close(sockfd);
613
			return -1;
618
			return -1;
614
		}
619
		}
615
		PILCallLog(LOG, PIL_INFO, "ucast: set SO_REUSEPORT(w)");
620
	} else
616
	}
621
		PILCallLog(LOG, PIL_INFO, "ucast: set SO_REUSEPORT");
617
#endif
622
#endif
618
623
619
	/* Try binding a few times before giving up */
624
	/* Try binding a few times before giving up */

Return to bug 486186