Arnaldo Carvalho de Melo
2ff52f282c
[TCP]: Change tcp_header_len member in tcp_sock to u16
...
With this we eliminate the last hole in struct tcp_sock.
End result:
[acme@newtoy net-2.6.20]$ codiff -sV /tmp/tcp.o.before net/ipv4/tcp.o
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv4/tcp.c:
struct tcp_sock | -4
tcp_header_len;
from: int /* 1000(0) 4(0) */
to: u16 /* 1000(0) 2(0) */
1 struct changed
[acme@newtoy net-2.6.20]$
Now sizeof(tcp_sock) is just...
[acme@newtoy net-2.6.20]$ pahole --sizes ../OUTPUT/qemu/net-2.6.20/net/ipv4/tcp.o | grep -w tcp_sock
struct tcp_sock: 1500 0
1500 bytes ;-)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com >
2006-12-02 21:30:53 -08:00
Arnaldo Carvalho de Melo
46ca5f5dc4
[XFRM]: Pack struct xfrm_policy
...
[acme@newtoy net-2.6.20]$ pahole net/ipv4/tcp.o xfrm_policy
/* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/linux/security.h:67 */
struct xfrm_policy {
struct xfrm_policy * next; /* 0 4 */
struct hlist_node bydst; /* 4 8 */
struct hlist_node byidx; /* 12 8 */
rwlock_t lock; /* 20 36 */
atomic_t refcnt; /* 56 4 */
struct timer_list timer; /* 60 24 */
u8 type; /* 84 1 */
/* XXX 3 bytes hole, try to pack */
u32 priority; /* 88 4 */
u32 index; /* 92 4 */
struct xfrm_selector selector; /* 96 56 */
struct xfrm_lifetime_cfg lft; /* 152 64 */
struct xfrm_lifetime_cur curlft; /* 216 32 */
struct dst_entry * bundles; /* 248 4 */
__u16 family; /* 252 2 */
__u8 action; /* 254 1 */
__u8 flags; /* 255 1 */
__u8 dead; /* 256 1 */
__u8 xfrm_nr; /* 257 1 */
/* XXX 2 bytes hole, try to pack */
struct xfrm_sec_ctx * security; /* 260 4 */
struct xfrm_tmpl xfrm_vec[6]; /* 264 360 */
}; /* size: 624, sum members: 619, holes: 2, sum holes: 5 */
So lets have just one hole instead of two, by moving 'type' to just before 'action',
end result:
[acme@newtoy net-2.6.20]$ codiff -s /tmp/tcp.o.before net/ipv4/tcp.o
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv4/tcp.c:
struct xfrm_policy | -4
1 struct changed
[acme@newtoy net-2.6.20]$
[acme@newtoy net-2.6.20]$ pahole -c 64 net/ipv4/tcp.o xfrm_policy
/* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/linux/security.h:67 */
struct xfrm_policy {
struct xfrm_policy * next; /* 0 4 */
struct hlist_node bydst; /* 4 8 */
struct hlist_node byidx; /* 12 8 */
rwlock_t lock; /* 20 36 */
atomic_t refcnt; /* 56 4 */
struct timer_list timer; /* 60 24 */
u32 priority; /* 84 4 */
u32 index; /* 88 4 */
struct xfrm_selector selector; /* 92 56 */
struct xfrm_lifetime_cfg lft; /* 148 64 */
struct xfrm_lifetime_cur curlft; /* 212 32 */
struct dst_entry * bundles; /* 244 4 */
u16 family; /* 248 2 */
u8 type; /* 250 1 */
u8 action; /* 251 1 */
u8 flags; /* 252 1 */
u8 dead; /* 253 1 */
u8 xfrm_nr; /* 254 1 */
/* XXX 1 byte hole, try to pack */
struct xfrm_sec_ctx * security; /* 256 4 */
struct xfrm_tmpl xfrm_vec[6]; /* 260 360 */
}; /* size: 620, sum members: 619, holes: 1, sum holes: 1 */
Are there any fugly data dependencies here? None that I know.
In the process changed the removed the __ prefixed types, that are just for
userspace visible headers.
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com >
2006-12-02 21:30:48 -08:00
Arnaldo Carvalho de Melo
d5c42c0ec4
[NET]: Pack struct hh_cache
...
[acme@newtoy net-2.6.20]$ pahole net/ipv4/tcp.o hh_cache
/* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/linux/netdevice.h:190 */
struct hh_cache {
struct hh_cache * hh_next; /* 0 4 */
atomic_t hh_refcnt; /* 4 4 */
__be16 hh_type; /* 8 2 */
/* XXX 2 bytes hole, try to pack */
int hh_len; /* 12 4 */
int (*hh_output)(); /* 16 4 */
rwlock_t hh_lock; /* 20 36 */
long unsigned int hh_data[24]; /* 56 96 */
}; /* size: 152, sum members: 150, holes: 1, sum holes: 2 */
[acme@newtoy net-2.6.20]$ find net -name "*.[ch]" | xargs grep 'hh_len.\+=' | sort -u
net/atm/br2684.c: hh->hh_len = PADLEN + ETH_HLEN;
net/ethernet/eth.c: hh->hh_len = ETH_HLEN;
net/ipv4/ipconfig.c: int hh_len = LL_RESERVED_SPACE(dev);
net/ipv4/ip_output.c: hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
net/ipv4/ip_output.c: int hh_len = LL_RESERVED_SPACE(dev);
net/ipv4/netfilter.c: hh_len = (*pskb)->dst->dev->hard_header_len;
net/ipv4/raw.c: hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
net/ipv6/ip6_output.c: hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
net/ipv6/netfilter/ip6t_REJECT.c: hh_len = (dst->dev->hard_header_len + 15)&~15;
net/ipv6/raw.c: hh_len = LL_RESERVED_SPACE(rt->u.dst.dev);
[acme@newtoy net-2.6.20]$
[acme@newtoy net-2.6.20]$ find include -name "*.h" | xargs grep 'define ETH_HLEN'
include/linux/if_ether.h:#define ETH_HLEN 14 /* Total octets in header. */
(((dev)->hard_header_len&~(HH_DATA_MOD - 1)) + HH_DATA_MOD)
[acme@newtoy net-2.6.20]$ pahole net/ipv4/tcp.o net_device | grep hard_header_len
short unsigned int hard_header_len; /* 106 2 */
[acme@newtoy net-2.6.20]$
So I think we're safe in turning hh_len an u16, end result:
[acme@newtoy net-2.6.20]$ codiff -sV /tmp/tcp.o.before net/ipv4/tcp.o
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv4/tcp.c:
struct hh_cache | -4
hh_len;
from: int /* 12(0) 4(0) */
to: u16 /* 10(0) 2(0) */
1 struct changed
[acme@newtoy net-2.6.20]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com >
2006-12-02 21:30:47 -08:00
Arnaldo Carvalho de Melo
850db6b8c5
[INET_CONNECTION_SOCK]: Pack struct inet_connection_sock_af_ops
...
We have a hole in:
[acme@newtoy net-2.6.20]$ pahole net/ipv6/tcp_ipv6.o inet_connection_sock_af_ops
/* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/net/inet_connection_sock.h:38 */
struct inet_connection_sock_af_ops {
int (*queue_xmit)(); /* 0 4 */
void (*send_check)(); /* 4 4 */
int (*rebuild_header)(); /* 8 4 */
int (*conn_request)(); /* 12 4 */
struct sock * (*syn_recv_sock)(); /* 16 4 */
int (*remember_stamp)(); /* 20 4 */
__u16 net_header_len; /* 24 2 */
/* XXX 2 bytes hole, try to pack */
int (*setsockopt)(); /* 28 4 */
int (*getsockopt)(); /* 32 4 */
int (*compat_setsockopt)(); /* 36 4 */
int (*compat_getsockopt)(); /* 40 4 */
void (*addr2sockaddr)(); /* 44 4 */
int sockaddr_len; /* 48 4 */
}; /* size: 52, sum members: 50, holes: 1, sum holes: 2 */
But we don't need sockaddr_len to be an int:
[acme@newtoy net-2.6.20]$ find net -name "*.[ch]" | xargs grep '\.sockaddr_len.\+=' | sort -u
net/dccp/ipv4.c: .sockaddr_len = sizeof(struct sockaddr_in),
net/dccp/ipv6.c: .sockaddr_len = sizeof(struct sockaddr_in6),
net/ipv4/tcp_ipv4.c: .sockaddr_len = sizeof(struct sockaddr_in),
net/ipv6/tcp_ipv6.c: .sockaddr_len = sizeof(struct sockaddr_in6),
net/sctp/ipv6.c: .sockaddr_len = sizeof(struct sockaddr_in6),
net/sctp/protocol.c: .sockaddr_len = sizeof(struct sockaddr_in),
[acme@newtoy net-2.6.20]$ pahole --sizes net/ipv6/tcp_ipv6.o | grep sockaddr_in
struct sockaddr_in: 16 0
struct sockaddr_in6: 28 0
[acme@newtoy net-2.6.20]$
So I turned sockaddr_len a 'u16', and now:
[acme@newtoy net-2.6.20]$ pahole net/ipv6/tcp_ipv6.o inet_connection_sock_af_ops
/* /pub/scm/linux/kernel/git/acme/net-2.6.20/include/net/inet_connection_sock.h:38 */
struct inet_connection_sock_af_ops {
int (*queue_xmit)(); /* 0 4 */
void (*send_check)(); /* 4 4 */
int (*rebuild_header)(); /* 8 4 */
int (*conn_request)(); /* 12 4 */
struct sock * (*syn_recv_sock)(); /* 16 4 */
int (*remember_stamp)(); /* 20 4 */
u16 net_header_len; /* 24 2 */
u16 sockaddr_len; /* 26 2 */
int (*setsockopt)(); /* 28 4 */
int (*getsockopt)(); /* 32 4 */
int (*compat_setsockopt)(); /* 36 4 */
int (*compat_getsockopt)(); /* 40 4 */
void (*addr2sockaddr)(); /* 44 4 */
}; /* size: 48 */
So we've saved 4 bytes:
[acme@newtoy net-2.6.20]$ codiff -sV /tmp/tcp_ipv6.o.before net/ipv6/tcp_ipv6.o
/pub/scm/linux/kernel/git/acme/net-2.6.20/net/ipv6/tcp_ipv6.c:
struct inet_connection_sock_af_ops | -4
net_header_len;
from: __u16 /* 24(0) 2(0) */
to: u16 /* 24(0) 2(0) */
sockaddr_len;
from: int /* 48(0) 4(0) */
to: u16 /* 26(0) 2(0) */
1 struct changed
[acme@newtoy net-2.6.20]$
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com >
2006-12-02 21:30:46 -08:00
Gerrit Renker
4c0a6cb0db
[UDP(-Lite)]: consolidate v4 and v6 get|setsockopt code
...
This patch consolidates set/getsockopt code between UDP(-Lite) v4 and 6. The
justification is that UDP(-Lite) is a transport-layer protocol and therefore
the socket option code (at least in theory) should be AF-independent.
Furthermore, there is the following code reduplication:
* do_udp{,v6}_getsockopt is 100% identical between v4 and v6
* do_udp{,v6}_setsockopt is identical up to the following differerence
--v4 in contrast to v4 additionally allows the experimental encapsulation
types UDP_ENCAP_ESPINUDP and UDP_ENCAP_ESPINUDP_NON_IKE
--the remainder is identical between v4 and v6
I believe that this difference is of little relevance.
The advantages in not duplicating twice almost completely identical code.
The patch further simplifies the interface of udp{,v6}_push_pending_frames,
since for the second argument (struct udp_sock *up) it always holds that
up = udp_sk(sk); where sk is the first function argument.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:30:45 -08:00
Thomas Graf
e3703b3de1
[RTNETLINK]: Add rtnl_put_cacheinfo() to unify some code
...
IPv4, IPv6, and DECNet all use struct rta_cacheinfo in a similiar
way, therefore rtnl_put_cacheinfo() is added to reuse code.
Signed-off-by: Thomas Graf <tgraf@suug.ch >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:30:44 -08:00
Thomas Graf
4e9b826935
[NETLINK]: Remove unused dst_pid field in netlink_skb_parms
...
The destination PID is passed directly to netlink_unicast()
respectively netlink_multicast().
Signed-off-by: Thomas Graf <tgraf@suug.ch >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:30:43 -08:00
Gerrit Renker
d61c167dd0
[NET]: Add documentation for TFRC structures
...
This adds documentation for the TFRC structure fields.
Signed-off-by: Gerrit Renker <gerrit@erg.abdn.ac.uk >
Signed-off-by: Ian McDonald <ian.mcdonald@jandi.co.nz >
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com >
2006-12-02 21:30:42 -08:00
Thomas Graf
4a89c2562c
[DECNET] address: Convert to new netlink interface
...
Extends the netlink interface to support the __le16 type and
converts address addition, deletion and, dumping to use the
new netlink interface.
Fixes multiple occasions of possible illegal memory references
due to not validated netlink attributes.
Signed-off-by: Thomas Graf <tgraf@suug.ch >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:30:30 -08:00
Al Viro
66c6f529c3
[NET]: net/sched annotations.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:19 -08:00
Al Viro
ff1dcadb1b
[NET]: Split skb->csum
...
... into anonymous union of __wsum and __u32 (csum and csum_offset resp.)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:18 -08:00
Al Viro
8e5200f540
[NET]: Fix assorted misannotations (from md5 and udplite merges).
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:16 -08:00
Al Viro
2178eda826
[SCTP]: SCTP_CMD_PROCESS_CTSN annotations.
...
argument passed as __be32
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:14 -08:00
Al Viro
962c837275
[SCTP]: Netfilter sctp annotations.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:12 -08:00
Al Viro
3dbe86566e
[SCTP]: Annotate ->supported_addrs().
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:11 -08:00
Al Viro
e1857ea28d
[SCTP]: sctp_association ->peer.i is a host-endian analog of sctp_inthdr.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:10 -08:00
Al Viro
6fbfa9f951
[SCTP]: Annotate ->inaddr_any().
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:08 -08:00
Al Viro
c9c938cb05
[SCTP]: flip_to_{h,n}() are not needed anymore.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:07 -08:00
Al Viro
516b20ee2d
[SCTP]: ->a_h is gone now.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:05 -08:00
Al Viro
74af924ab6
[SCTP]: ->a_h is gone now.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:27:00 -08:00
Al Viro
80f15d6241
[SCTP]: ->source_h is not used anymore.
...
kill it
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:26:57 -08:00
Al Viro
a926626893
[SCTP]: Switch all remaining users of ->saddr_h to ->saddr.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:26:56 -08:00
Al Viro
dd86d136f9
[SCTP]: Switch ->from_addr_param() to net-endian.
...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:26:48 -08:00
Al Viro
854d43a465
[SCTP]: Annotate ->dst_saddr()
...
switched to taking a pointer to net-endian sctp_addr
and a net-endian port number. Instances and callers
adjusted; interestingly enough, the only calls are
direct calls of specific instances - the method is not
used at all.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:26:35 -08:00
Al Viro
2a6fd78ade
[SCTP] embedded sctp_addr: net-endian mirrors
...
Add sctp_chunk->source, sctp_sockaddr_entry->a, sctp_transport->ipaddr
and sctp_transport->saddr, maintain them as net-endian mirrors of
their host-endian counterparts.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk >
Signed-off-by: David S. Miller <davem@davemloft.net >
2006-12-02 21:26:30 -08:00