public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Jonathan Haws <Jonathan.Haws@sdl.usu.edu>
To: "b.a.t.m.a.n@lists.open-mesh.org" <b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH v4] alfred: IPv4 multicast distribution support.
Date: Tue, 24 Jan 2017 15:35:33 +0000	[thread overview]
Message-ID: <1485272132.2398.4.camel@sdl.usu.edu> (raw)
In-Reply-To: <1899098.CrQhkxgaNY@bentobox>

> > @@ -273,10 +276,15 @@ static struct globals *alfred_init(int argc,
> > char *argv[])
> >  			return NULL;
> >  		case 'p':
> >  			sync_period = strtod(optarg, NULL);
> > -			globals->sync_period.tv_sec = (int)
> > sync_period;
> > -			globals->sync_period.tv_nsec = (double)
> > (sync_period - (int) sync_period) * 1e9;
> > +			globals->sync_period.tv_sec =
> > (int)sync_period;
> > +			globals->sync_period.tv_nsec =
> > (double)(sync_period - (int)sync_period) * 1e9;
> >  			printf(" ** Setting sync interval to: %.9f
> > seconds (%ld.%09ld)\n", sync_period, globals->sync_period.tv_sec,
> > globals->sync_period.tv_nsec);
> >  			break;
> This doesn't seem to belong in this patch.

Yes, that is correct.  I must have fixed that formatting when I was
going through everything else.  Would you like me to take it out of
this patch?

> > +static int netsock_open4(struct interface *interface)
> > +{
> > +	int sock;
> > +	int sock_mc;
> > +	struct sockaddr_in sin4, sin_mc;
> > +	struct ip_mreq mreq;
> > +	struct ifreq ifr;
> > +	int ret;
> > +
> > +	interface->netsock = -1;
> > +	interface->netsock_mcast = -1;
> > +
> > +	sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > +	if (sock  < 0) {
> > +		perror("ipv4: can't open socket");
> > +		return -1;
> > +	}
> > +
> > +	sock_mc = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
> > +	if (sock_mc  < 0) {
> > +		perror("ipv4: can't open mc socket");
> > +		return -1;
> > +	}
> You don't sock in this situation (on errors)?

Huh, I had saw that as well and thought I had it fixed.  I'll make sure
I didn't just miss a commit.

> > 
> > +	memset(&ifr, 0, sizeof(ifr));
> > +	strncpy(ifr.ifr_name, interface->interface, IFNAMSIZ);
> > +	ifr.ifr_name[IFNAMSIZ - 1] = '\0';
> > +	if (ioctl(sock_mc, SIOCGIFHWADDR, &ifr) == -1) {
> > +		perror("ipv4: can't get MAC address");
> > +		goto err4;
> And now (see err4) you only close sock_mc? This applies to basically
> the rest
> of the function. So I will skip it and not mention every place which
> looks
> suspicious.

Same comment as above.

> > 
> > +
> > +	interface->netsock = sock;
> > +	interface->netsock_mcast = sock_mc;
> > +
> > +	return 0;
> > +err4:
> > +	close(sock_mc);
> > +	return -1;
> > +}
> > +
> You only close sock_mc on errors but not sock?
> 
> And please chose something better [1] than err4.

I see why you'd want me to rename the goto - however it was chosen to
differentiate between the err goto in netsock_open.  I called it err4
since it is for the netsock_open4() function dealing with IPv4.  Would
err_ipv4 be better?


  reply	other threads:[~2017-01-24 15:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-20  4:01 [B.A.T.M.A.N.] [PATCH v4] alfred: IPv4 multicast distribution support Jonathan Haws
2017-01-20  4:04 ` Jonathan Haws
2017-01-24 11:44 ` Simon Wunderlich
2017-01-24 15:45   ` Jonathan Haws
2017-01-24 16:05     ` Simon Wunderlich
2017-01-24 16:07       ` Jonathan Haws
2017-01-24 13:05 ` Sven Eckelmann
2017-01-24 15:35   ` Jonathan Haws [this message]
2017-01-24 16:09     ` Simon Wunderlich
2017-01-24 16:19     ` Sven Eckelmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1485272132.2398.4.camel@sdl.usu.edu \
    --to=jonathan.haws@sdl.usu.edu \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox