Make loopattach() panic [was Re: A system without interface?]

2014-10-14 Thread Martin Pieuchot
On 14/10/14(Tue) 14:18, Claudio Jeker wrote:
> On Tue, Oct 14, 2014 at 11:01:46AM +0200, Martin Pieuchot wrote:
> > On 08/10/14(Wed) 14:29, Martin Pieuchot wrote:
> > > I'm looking after the uses of the global list of interface.  These ones
> > > are pointless, you always have at least one interface on your system.
> > > 
> > > Ok?
> > 
> > Anyone?
> 
> OK. But we should make loopattach() panic if it fails to clone lo0.

Makes sense, here's the diff.

Index: net/if_loop.c
===
RCS file: /home/ncvs/src/sys/net/if_loop.c,v
retrieving revision 1.58
diff -u -p -r1.58 if_loop.c
--- net/if_loop.c   7 Oct 2014 08:47:28 -   1.58
+++ net/if_loop.c   14 Oct 2014 12:39:50 -
@@ -154,7 +154,9 @@ struct if_clone loop_cloner =
 void
 loopattach(int n)
 {
-   (void) loop_clone_create(&loop_cloner, 0);
+   if (loop_clone_create(&loop_cloner, 0))
+   panic("unable to create lo0");
+
if_clone_attach(&loop_cloner);
 }
 



Re: A system without interface?

2014-10-14 Thread Claudio Jeker
On Tue, Oct 14, 2014 at 11:01:46AM +0200, Martin Pieuchot wrote:
> On 08/10/14(Wed) 14:29, Martin Pieuchot wrote:
> > I'm looking after the uses of the global list of interface.  These ones
> > are pointless, you always have at least one interface on your system.
> > 
> > Ok?
> 
> Anyone?

OK. But we should make loopattach() panic if it fails to clone lo0.

> 
> > 
> > Index: netinet/raw_ip.c
> > ===
> > RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v
> > retrieving revision 1.75
> > diff -u -p -r1.75 raw_ip.c
> > --- netinet/raw_ip.c14 Aug 2014 08:22:38 -  1.75
> > +++ netinet/raw_ip.c8 Oct 2014 12:25:31 -
> > @@ -457,7 +457,7 @@ rip_usrreq(struct socket *so, int req, s
> > error = EINVAL;
> > break;
> > }
> > -   if (TAILQ_EMPTY(&ifnet) || addr->sin_family != AF_INET) {
> > +   if (addr->sin_family != AF_INET) {
> > error = EADDRNOTAVAIL;
> > break;
> > }
> > @@ -477,10 +477,6 @@ rip_usrreq(struct socket *so, int req, s
> >  
> > if (nam->m_len != sizeof(*addr)) {
> > error = EINVAL;
> > -   break;
> > -   }
> > -   if (TAILQ_EMPTY(&ifnet)) {
> > -   error = EADDRNOTAVAIL;
> > break;
> > }
> > if (addr->sin_family != AF_INET) {
> > Index: netinet6/raw_ip6.c
> > ===
> > RCS file: /home/ncvs/src/sys/netinet6/raw_ip6.c,v
> > retrieving revision 1.68
> > diff -u -p -r1.68 raw_ip6.c
> > --- netinet6/raw_ip6.c  22 Jul 2014 11:06:10 -  1.68
> > +++ netinet6/raw_ip6.c  8 Oct 2014 12:25:31 -
> > @@ -665,7 +665,7 @@ rip6_usrreq(struct socket *so, int req, 
> > error = EINVAL;
> > break;
> > }
> > -   if (TAILQ_EMPTY(&ifnet) || (addr->sin6_family != AF_INET6)) {
> > +   if (addr->sin6_family != AF_INET6) {
> > error = EADDRNOTAVAIL;
> > break;
> > }
> > @@ -708,10 +708,6 @@ rip6_usrreq(struct socket *so, int req, 
> >  
> > if (nam->m_len != sizeof(*addr)) {
> > error = EINVAL;
> > -   break;
> > -   }
> > -   if (TAILQ_EMPTY(&ifnet)) {
> > -   error = EADDRNOTAVAIL;
> > break;
> > }
> > if (addr->sin6_family != AF_INET6) {
> > 
> 

-- 
:wq Claudio



Re: A system without interface?

2014-10-14 Thread Mike Belopuhov
On 14 October 2014 11:01, Martin Pieuchot  wrote:
> On 08/10/14(Wed) 14:29, Martin Pieuchot wrote:
>> I'm looking after the uses of the global list of interface.  These ones
>> are pointless, you always have at least one interface on your system.
>>
>> Ok?
>
> Anyone?
>

looks good to me. ok mikeb



Re: A system without interface?

2014-10-14 Thread Martin Pieuchot
On 08/10/14(Wed) 14:29, Martin Pieuchot wrote:
> I'm looking after the uses of the global list of interface.  These ones
> are pointless, you always have at least one interface on your system.
> 
> Ok?

Anyone?

> 
> Index: netinet/raw_ip.c
> ===
> RCS file: /home/ncvs/src/sys/netinet/raw_ip.c,v
> retrieving revision 1.75
> diff -u -p -r1.75 raw_ip.c
> --- netinet/raw_ip.c  14 Aug 2014 08:22:38 -  1.75
> +++ netinet/raw_ip.c  8 Oct 2014 12:25:31 -
> @@ -457,7 +457,7 @@ rip_usrreq(struct socket *so, int req, s
>   error = EINVAL;
>   break;
>   }
> - if (TAILQ_EMPTY(&ifnet) || addr->sin_family != AF_INET) {
> + if (addr->sin_family != AF_INET) {
>   error = EADDRNOTAVAIL;
>   break;
>   }
> @@ -477,10 +477,6 @@ rip_usrreq(struct socket *so, int req, s
>  
>   if (nam->m_len != sizeof(*addr)) {
>   error = EINVAL;
> - break;
> - }
> - if (TAILQ_EMPTY(&ifnet)) {
> - error = EADDRNOTAVAIL;
>   break;
>   }
>   if (addr->sin_family != AF_INET) {
> Index: netinet6/raw_ip6.c
> ===
> RCS file: /home/ncvs/src/sys/netinet6/raw_ip6.c,v
> retrieving revision 1.68
> diff -u -p -r1.68 raw_ip6.c
> --- netinet6/raw_ip6.c22 Jul 2014 11:06:10 -  1.68
> +++ netinet6/raw_ip6.c8 Oct 2014 12:25:31 -
> @@ -665,7 +665,7 @@ rip6_usrreq(struct socket *so, int req, 
>   error = EINVAL;
>   break;
>   }
> - if (TAILQ_EMPTY(&ifnet) || (addr->sin6_family != AF_INET6)) {
> + if (addr->sin6_family != AF_INET6) {
>   error = EADDRNOTAVAIL;
>   break;
>   }
> @@ -708,10 +708,6 @@ rip6_usrreq(struct socket *so, int req, 
>  
>   if (nam->m_len != sizeof(*addr)) {
>   error = EINVAL;
> - break;
> - }
> - if (TAILQ_EMPTY(&ifnet)) {
> - error = EADDRNOTAVAIL;
>   break;
>   }
>   if (addr->sin6_family != AF_INET6) {
>