Re: allow if_output to be specialised on ethernet interfaces

2018-12-11 Thread Claudio Jeker
On Wed, Dec 12, 2018 at 11:54:39AM +1000, David Gwynne wrote:
> this makes it nicer to set up a custom output routine on ethernet
> interfaces. rather than overwriting it after ether_ifattach is called,
> you can set it up with the rest of the callbacks and the ether layer
> will respect it.
> 
> ok?

Are you sure that all ifp are allocated with zeroed out memory?
Apart from that OK claudio@
 
> Index: if_ethersubr.c
> ===
> RCS file: /cvs/src/sys/net/if_ethersubr.c,v
> retrieving revision 1.254
> diff -u -p -r1.254 if_ethersubr.c
> --- if_ethersubr.c11 Dec 2018 01:27:08 -  1.254
> +++ if_ethersubr.c11 Dec 2018 23:48:17 -
> @@ -510,7 +510,8 @@ ether_ifattach(struct ifnet *ifp)
>   ifp->if_addrlen = ETHER_ADDR_LEN;
>   ifp->if_hdrlen = ETHER_HDR_LEN;
>   ifp->if_mtu = ETHERMTU;
> - ifp->if_output = ether_output;
> + if (ifp->if_output == NULL)
> + ifp->if_output = ether_output;
>   ifp->if_rtrequest = ether_rtrequest;
>  
>   if_ih_insert(ifp, ether_input, NULL);
> 

-- 
:wq Claudio



allow if_output to be specialised on ethernet interfaces

2018-12-11 Thread David Gwynne
this makes it nicer to set up a custom output routine on ethernet
interfaces. rather than overwriting it after ether_ifattach is called,
you can set it up with the rest of the callbacks and the ether layer
will respect it.

ok?

Index: if_ethersubr.c
===
RCS file: /cvs/src/sys/net/if_ethersubr.c,v
retrieving revision 1.254
diff -u -p -r1.254 if_ethersubr.c
--- if_ethersubr.c  11 Dec 2018 01:27:08 -  1.254
+++ if_ethersubr.c  11 Dec 2018 23:48:17 -
@@ -510,7 +510,8 @@ ether_ifattach(struct ifnet *ifp)
ifp->if_addrlen = ETHER_ADDR_LEN;
ifp->if_hdrlen = ETHER_HDR_LEN;
ifp->if_mtu = ETHERMTU;
-   ifp->if_output = ether_output;
+   if (ifp->if_output == NULL)
+   ifp->if_output = ether_output;
ifp->if_rtrequest = ether_rtrequest;
 
if_ih_insert(ifp, ether_input, NULL);