Discussion:
eliminate struct protosw::pr_output
(too old to reply)
Taylor R Campbell
2016-01-16 23:57:13 UTC
Permalink
The ip_output function must be called as

ip_output(m, opt, ro, flags, mopt, so)

where the arguments have the types

struct mbuf *m;
struct mbuf *opt;
struct route *ro;
int flags;
struct ip_moptions *mopt;
struct socket *so;

However, the prototype for ip_output is variadic:

int ip_output(struct mbuf *, ...);

This is silly. The only reason it is like this is that it is put in
the pr_output member of a struct protosw somewhere -- and then never
used via that path. There's no way you could use it if you didn't
know the protocol you were using, so this pr_output member can't be
used anyway unless you know a priori that you're in netinet. The same
is true of every other pr_output routine.

The only pr_output members that are ever actually used are (net/route)
rtsock's and (netipsec) keysock's, via raw_send.

The attached patch eliminates the pr_output member of struct protosw
(and struct ip6protosw), and adds an explicit (fully typed) callback
to raw_send for use by rtsock and keysock.

A subsequent patch may give ip_output &c. fully typed prototypes and
avoid varargs altogether, but I'll defer that for now. I would like
to apply similar treatment to pr_input, but again in another (somewhat
more involved) patch.

Thoughts? Objections?
Kengo NAKAHARA
2016-01-19 03:55:18 UTC
Permalink
Hi,
Post by Taylor R Campbell
The ip_output function must be called as
ip_output(m, opt, ro, flags, mopt, so)
where the arguments have the types
struct mbuf *m;
struct mbuf *opt;
struct route *ro;
int flags;
struct ip_moptions *mopt;
struct socket *so;
int ip_output(struct mbuf *, ...);
This is silly. The only reason it is like this is that it is put in
the pr_output member of a struct protosw somewhere -- and then never
used via that path. There's no way you could use it if you didn't
know the protocol you were using, so this pr_output member can't be
used anyway unless you know a priori that you're in netinet. The same
is true of every other pr_output routine.
The only pr_output members that are ever actually used are (net/route)
rtsock's and (netipsec) keysock's, via raw_send.
The attached patch eliminates the pr_output member of struct protosw
(and struct ip6protosw), and adds an explicit (fully typed) callback
to raw_send for use by rtsock and keysock.
A subsequent patch may give ip_output &c. fully typed prototypes and
avoid varargs altogether, but I'll defer that for now. I would like
to apply similar treatment to pr_input, but again in another (somewhat
more involved) patch.
Thoughts? Objections?
I agree. The patch looks good to me.
I think you could commit it.


Thanks,
--
//////////////////////////////////////////////////////////////////////
Internet Initiative Japan Inc.

Device Engineering Section,
Core Product Development Department,
Product Division,
Technology Unit

Kengo NAKAHARA <k-***@iij.ad.jp>

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Christos Zoulas
2016-01-19 15:36:55 UTC
Permalink
Post by Kengo NAKAHARA
Hi,
Post by Taylor R Campbell
The ip_output function must be called as
ip_output(m, opt, ro, flags, mopt, so)
where the arguments have the types
struct mbuf *m;
struct mbuf *opt;
struct route *ro;
int flags;
struct ip_moptions *mopt;
struct socket *so;
int ip_output(struct mbuf *, ...);
This is silly. The only reason it is like this is that it is put in
the pr_output member of a struct protosw somewhere -- and then never
used via that path. There's no way you could use it if you didn't
know the protocol you were using, so this pr_output member can't be
used anyway unless you know a priori that you're in netinet. The same
is true of every other pr_output routine.
The only pr_output members that are ever actually used are (net/route)
rtsock's and (netipsec) keysock's, via raw_send.
The attached patch eliminates the pr_output member of struct protosw
(and struct ip6protosw), and adds an explicit (fully typed) callback
to raw_send for use by rtsock and keysock.
A subsequent patch may give ip_output &c. fully typed prototypes and
avoid varargs altogether, but I'll defer that for now. I would like
to apply similar treatment to pr_input, but again in another (somewhat
more involved) patch.
Thoughts? Objections?
I agree. The patch looks good to me.
I think you could commit it.
Go for it (i am the one who made ip_output varyadic around 1994 for netccitt).

christos


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Loading...