On Tue, Oct 27, 2015 at 01:40:04PM +0100, Martin Pieuchot wrote: > On 25/10/15(Sun) 16:21, Sebastian Benoit wrote: > > Martin Pieuchot(m...@openbsd.org) on 2015.10.25 16:14:27 +0100: > > > Diff below merges the guts of rtable_mpath_match() into rtable_lookup(). > > > As for the previous rtable_mpath_* diff this is a step towards MPATH by > > > default. > > > > > > This diff introduces a behavior change for RTM_GET. If multiple route > > > exists a gateway MUST be specified and the first one in the tree won't > > > be automagically selected by the kernel. > > After discussion here's a diff that do almost the same refactoring but > without introducing a behavior change. ok?
Two nits. > @@ -264,6 +264,16 @@ rtable_lookup(unsigned int rtableid, str > return (NULL); > > rt = ((struct rtentry *)rn); > + > +#ifndef SMALL_KERNEL > + if (rnh->rnh_multipath) { > + rt = rt_mpath_matchgate(rt, gateway, prio); > + if (rt == NULL) > + return (NULL); > + } > + Please do not add too many new lines. > +#endif /* !SMALL_KERNEL */ > + > rtref(rt); > > return (rt); > @@ -620,51 +620,36 @@ route_output(struct mbuf *m, ...) > error = EAFNOSUPPORT; > goto flush; > } > + > rt = rtable_lookup(tableid, info.rti_info[RTAX_DST], > - info.rti_info[RTAX_NETMASK]); > - if (rt == NULL) { > - error = ESRCH; > - goto flush; > + info.rti_info[RTAX_NETMASK], info.rti_info[RTAX_GATEWAY], > + prio); > +#ifdef SMALL_KERNEL I think this should be #ifndef > + /* > + * If we got multipath routes, we require users to specify > + * a matching gateway, except for RTM_GET. > + */ > + if ((rt != NULL) && ISSET(rt->rt_flags, RTF_MPATH) && > + (info.rti_info[RTAX_GATEWAY] == NULL) && > + (rtm->rtm_type != RTM_GET)) { > + rtfree(rt); > + rt = NULL; > } Otherwise OK bluhm@