Reflector patches: multicast/background and mbone ADMIT

Markus Buchhorn (markus@octavia.anu.edu.au)
Thu, 1 Jun 1995 10:35:38 +1000


G'day all

It has been commented on repeatedly here that using the reflector 3.0b3 with
multicast receive/send options turned on will generate an error of
the form:

> recvfrom error on XXX : Socket operation on non-socket: FATAL ERROR: EXITING

This happens either immediately (if run in background) or on any
terminal input (if run in the foreground). If multicast is not used, only
unicast, the problem does not appear.

I finally tracked this down to some 'loose' code in socket.c, where
it tries to suck from a pipe that isn't actually open :-( e.g. with nv_ucast
turned *off* and only mcast, the above XXX can be nv_ucast_sock !!

[To the source maintainers: FD_ISSET(0,p) always returns 1. In most
places you've checked for this, but in several you've forgotten to ...]

Save the following text (between 'cut here' lines) as 'sock.patch' in
your reflector source directory, and apply with 'patch < sock.patch'
to generate a new socket.c - recompile and away you go. I have it running
here at the moment, in the background, and no problems so far.

I also include a second patch, to reflect.c, which allows you to apply
the ADMIT rules to the MBONE side of the network (unicast and multicast).
This patch was developed by my colleague John Barlow (jdb@cisr.anu.edu.au).
This allows us to set up a restricted list of mixed machines, either
side of the reflector. Thus only those machines can join in. This won't
stop multicast traffic between the other machines though, since that bypasses
the reflector :-). Basically very useful in a fully unicast setup where
all participants are connecting to the reflector. Save as reflect.patch
and apply with 'patch < reflect.patch'.

Hope these patches help some people !

Cheers,
Markus

Markus Buchhorn, Parallel Computing Research Facility
email = markus@octavia.anu.edu.au snail = CISR, I Block, OAA, ANU
Australian National University, Canberra, 0200 , Australia.
[International = +61 6, Australia = 06] [Phone = 2492930, Fax = 2490747]

------- start sock.patch ------- cut here -----------------------------
*** socket.c.ORIG Thu Jun 1 09:55:14 1995
--- socket.c Thu Jun 1 09:54:28 1995
***************
*** 50,56 ****
unsigned char loop;


-
if (nv_ucast_port != 0){

if ((nv_ucast_sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0)
--- 50,55 ----
***************
*** 532,538 ****
if (nv_inout_mcast.sin_addr.s_addr)
FD_SET(nv_inout_mcast_sock,&readfds);

-
#endif
if (msg_sock == 0)
FD_SET(cntrl_sock, &readfds);
--- 531,536 ----
***************
*** 553,559 ****

cadrlen = sizeof(struct sockaddr_in);

! if (FD_ISSET(vid_sock, &readfds))
{

if ((*msglen = recvfrom(vid_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
--- 551,557 ----

cadrlen = sizeof(struct sockaddr_in);

! if ((vid_sock) && (FD_ISSET(vid_sock, &readfds)) )
{

if ((*msglen = recvfrom(vid_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
***************
*** 567,573 ****
return(VIDEO);
}

! if (FD_ISSET(nv_ucast_sock, &readfds))
{

if ((*msglen = recvfrom(nv_ucast_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
--- 565,571 ----
return(VIDEO);
}

! if ((nv_ucast_sock) && (FD_ISSET(nv_ucast_sock, &readfds)))
{

if ((*msglen = recvfrom(nv_ucast_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
***************
*** 577,589 ****

my_perror("recvfrom error on nv_ucast_sock");
}
if (debug)
printf("packet received through nv_ucast_sock\n");
return(NV_UCAST);
}

!
! if (FD_ISSET(maven_sock, &readfds))
{

if ((*msglen = recvfrom(maven_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
--- 575,587 ----

my_perror("recvfrom error on nv_ucast_sock");
}
+
if (debug)
printf("packet received through nv_ucast_sock\n");
return(NV_UCAST);
}

! if ((maven_sock) && (FD_ISSET(maven_sock, &readfds)) )
{

if ((*msglen = recvfrom(maven_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
***************
*** 598,604 ****
return(MAVEN);
}

! if (FD_ISSET(maven_cntl_sock, &readfds))
{

if ((*msglen = recvfrom(maven_cntl_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
--- 596,602 ----
return(MAVEN);
}

! if ((maven_cntl_sock) && (FD_ISSET(maven_cntl_sock, &readfds)) )
{

if ((*msglen = recvfrom(maven_cntl_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
***************
*** 675,681 ****

}

! if (FD_ISSET(vat_cntl_mcast_sock, &readfds))
{

if ((*msglen = recvfrom(vat_cntl_mcast_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
--- 673,679 ----

}

! if ((vat_cntl_mcast_sock) && (FD_ISSET(vat_cntl_mcast_sock, &readfds)) )
{

if ((*msglen = recvfrom(vat_cntl_mcast_sock,pkt,MAXMSG,0,caddr,&cadrlen)) < 0)
***************
*** 726,732 ****

#endif

! if (FD_ISSET(cntrl_sock, &readfds))
{
if (msg_sock != 0)
{
--- 724,730 ----

#endif

! if ((cntrl_sock) && (FD_ISSET(cntrl_sock, &readfds)) )
{
if (msg_sock != 0)
{
***************
*** 761,767 ****
continue;
}

! if (FD_ISSET(msg_sock, &readfds))
{
if ((*msglen = recv(msg_sock,pkt,MAXMSG,0)) < 0)
{
--- 759,765 ----
continue;
}

! if ((msg_sock) && (FD_ISSET(msg_sock, &readfds)) )
{
if ((*msglen = recv(msg_sock,pkt,MAXMSG,0)) < 0)
{
--------- end sock.patch ------- cut here ------------------------

-------- start reflect.patch ---- cut here ----------------------
*** reflect.c.ORIG Thu Jun 1 09:55:03 1995
--- reflect.c Wed May 31 15:34:07 1995
***************
*** 51,57 ****
struct timeval tp;
struct timezone tzp;
char *tmp;
!

argc--; argv++;

--- 51,58 ----
struct timeval tp;
struct timezone tzp;
char *tmp;
! int goodmbone;
! int cnt;

argc--; argv++;

***************
*** 137,143 ****
type = receive(msg,&msglen,&csock);
pkts_in++;
bytes_in += msglen;
-
if (deny(csock))
{
clnt_addr.sin_family = AF_INET;
--- 138,143 ----
***************
*** 158,164 ****
case NV_UCAST:
case NV_MCAST:

! mbone_pkt(msg,msglen,csock,type);
break;

case REF1VIDEO:
--- 158,177 ----
case NV_UCAST:
case NV_MCAST:

! if (restrict_cnt != 0)
! {
! goodmbone=0;
! for (cnt=0; cnt<restrict_cnt; cnt++)
! if (restrict_list[cnt] == csock.sin_addr.s_addr)
! goodmbone=1;
! if (goodmbone)
! mbone_pkt(msg,msglen,csock,type);
! else
! dolog("packet from %s being dropped due to restrictions\n",
! inet_ntoa(csock.sin_addr));
! }
! else
! mbone_pkt(msg,msglen,csock,type);
break;

case REF1VIDEO:

------------ end reflect.patch ---- cut here --------------------