Discussion:
should rt_msg1() zero rt_msghdr?
(too old to reply)
J.T. Conklin
2008-05-16 18:02:34 UTC
Permalink
While debugging a problem with routing socket messages, I noticed that
messages contained random data in the rtm_seq, rtm_pid, and rtm_errno
fields.

In TCP/IP Illustrated, rt_msg1() contains a bzero() to clear rt_msghdr
fields. This bzero() is not present in NetBSD-4 (which I am using) or
in the -current sources.

Should a memset() be added where the bzero() used to be?

--jtc
--
J.T. Conklin

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Christos Zoulas
2008-05-16 20:05:51 UTC
Permalink
Post by J.T. Conklin
While debugging a problem with routing socket messages, I noticed that
messages contained random data in the rtm_seq, rtm_pid, and rtm_errno
fields.
In TCP/IP Illustrated, rt_msg1() contains a bzero() to clear rt_msghdr
fields. This bzero() is not present in NetBSD-4 (which I am using) or
in the -current sources.
Should a memset() be added where the bzero() used to be?
--jtc
--
J.T. Conklin
Can you post a diff?

christos


--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
J.T. Conklin
2008-05-16 21:33:07 UTC
Permalink
Post by Christos Zoulas
Post by J.T. Conklin
While debugging a problem with routing socket messages, I noticed that
messages contained random data in the rtm_seq, rtm_pid, and rtm_errno
fields.
In TCP/IP Illustrated, rt_msg1() contains a bzero() to clear rt_msghdr
fields. This bzero() is not present in NetBSD-4 (which I am using) or
in the -current sources.
Should a memset() be added where the bzero() used to be?
Can you post a diff?
This patch with memset() is equivalent to the version in TCP/IP
Illustrated that used bzero(). I'm building a kernel with this
change as I write this, so I haven't yet had a chance to verify
it.

--jtc


Index: rtsock.c
===================================================================
RCS file: /cvsroot/src/sys/net/rtsock.c,v
retrieving revision 1.103
diff -u -r1.103 rtsock.c
--- rtsock.c 13 May 2008 20:16:30 -0000 1.103
+++ rtsock.c 16 May 2008 21:27:54 -0000
@@ -586,6 +586,7 @@
m->m_pkthdr.rcvif = NULL;
m_copyback(m, 0, datalen, data);
rtm = mtod(m, struct rt_msghdr *);
+ memset(rtm, 0, len);
for (i = 0; i < RTAX_MAX; i++) {
if ((sa = rtinfo->rti_info[i]) == NULL)
continue;
--
J.T. Conklin

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Christos Zoulas
2008-05-16 22:07:20 UTC
Permalink
On May 16, 2:33pm, ***@acorntoolworks.com (J.T. Conklin) wrote:
-- Subject: Re: should rt_msg1() zero rt_msghdr?

| ***@astron.com (Christos Zoulas) writes:
| > In article <***@orac.acorntoolworks.com>,
| > J.T. Conklin <***@acorntoolworks.com> wrote:
| >>While debugging a problem with routing socket messages, I noticed that
| >>messages contained random data in the rtm_seq, rtm_pid, and rtm_errno
| >>fields.
| >>
| >>In TCP/IP Illustrated, rt_msg1() contains a bzero() to clear rt_msghdr
| >>fields. This bzero() is not present in NetBSD-4 (which I am using) or
| >>in the -current sources.
| >>
| >>Should a memset() be added where the bzero() used to be?
| >
| > Can you post a diff?
|
| This patch with memset() is equivalent to the version in TCP/IP
| Illustrated that used bzero(). I'm building a kernel with this
| change as I write this, so I haven't yet had a chance to verify
| it.

I think this is right. Should the same be done in rt_msg2()?

christos

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
J.T. Conklin
2008-05-16 22:33:23 UTC
Permalink
Post by Christos Zoulas
I think this is right. Should the same be done in rt_msg2()?
Unlike rt_msg1(), rt_msg2() is passed the struct that will be filled
in. I looked at all callers, and it appears that in each case it is
zeroed before rt_msg2() is called. So it while it wouldn't hurt, it
does not look like it's necessary.

--jtc
--
J.T. Conklin

--
Posted automagically by a mail2news gateway at muc.de e.V.
Please direct questions, flames, donations, etc. to news-***@muc.de
Christos Zoulas
2008-05-16 23:12:29 UTC
Permalink
On May 16, 3:33pm, ***@acorntoolworks.com (J.T. Conklin) wrote:
-- Subject: Re: should rt_msg1() zero rt_msghdr?

| ***@zoulas.com (Christos Zoulas) writes:
| > I think this is right. Should the same be done in rt_msg2()?
|
| Unlike rt_msg1(), rt_msg2() is passed the struct that will be filled
| in. I looked at all callers, and it appears that in each case it is
| zeroed before rt_msg2() is called. So it while it wouldn't hurt, it
| does not look like it's necessary.
|
| --jtc

Great, let's just zero the one in rt_msg1().

christos

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