Subject: struct route
To: None <tech-net@netbsd.org>
From: Jun-ichiro itojun Hagino <itojun@iijlab.net>
List: tech-net
Date: 07/13/2000 03:14:46
sys/net/route.h has struct route, which is like this:
struct route {
struct rtentry *ro_rt;
struct sockaddr ro_dst;
};
This cannot hold sockaddr_iso or sockaddr_in6 (as sizeof(sockaddr) <
sizeof(sockaddr_in6)), so there are local declarations for
struct route-lookalike, in netiso (sys/netiso/iso_pcb.h) and netinet6
(sys/netinet6/in6.h). the approach has three issues, I believe:
(1) maintenance nightmare.
(2) offsetof(struct route, ro_dst) may not be equal to
offsetof(struct route_in6, ro_dst), as we are unsure about
struct packing rule by the compiler
(3) if we mistakenly make a struct route_in6 * point to struct route
region, we will easily make a overrun.
so, we'd like to change it as follows:
struct route {
struct rtentry *ro_rt;
struct sockaddr ro_dst;
char padding[sizeof(struct sockaddr_storage) - sizeof(struct sockaddr)];
};
and nuke special route-like structure in netiso/netinet6.
the above change should not raise type issue against existing code
(like sys/netinet), as we do not change the type of ro_dst.
since struct route is kernel-only structure, the change should not
raise binary compatibility problem against the userland.
is it okay for you guys? we are now testing this in kame tree and
is working fine.
itojun