OpenWrt – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | From 704f3acfcf55343043bbed01c5fb0a0094a68e8a Mon Sep 17 00:00:00 2001 |
2 | From: Denis Pynkin <denis.pynkin@collabora.com> |
||
3 | Date: Fri, 21 Jul 2017 19:28:42 +0300 |
||
4 | Subject: [PATCH] net: Use packed structures for networking |
||
5 | |||
6 | PXE boot is broken with GCC 7.1 due option '-fstore-merging' enabled |
||
7 | by default for '-O2': |
||
8 | |||
9 | BOOTP broadcast 1 |
||
10 | data abort |
||
11 | pc : [<8ff8bb30>] lr : [<00004f1f>] |
||
12 | reloc pc : [<17832b30>] lr : [<878abf1f>] |
||
13 | sp : 8f558bc0 ip : 00000000 fp : 8ffef5a4 |
||
14 | r10: 8ffed248 r9 : 8f558ee0 r8 : 8ffef594 |
||
15 | r7 : 0000000e r6 : 8ffed700 r5 : 00000000 r4 : 8ffed74e |
||
16 | r3 : 00060101 r2 : 8ffed230 r1 : 8ffed706 r0 : 00000ddd |
||
17 | Flags: nzcv IRQs off FIQs off Mode SVC_32 |
||
18 | Resetting CPU ... |
||
19 | |||
20 | Core reason is usage of structures for network headers without packed |
||
21 | attribute. |
||
22 | |||
23 | Reviewed-by: Yauheni Kaliuta <yauheni.kaliuta@redhat.com> |
||
24 | Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com> |
||
25 | Acked-by: Joe Hershberger <joe.hershberger@ni.com> |
||
26 | --- |
||
27 | include/net.h | 14 +++++++------- |
||
28 | net/bootp.h | 2 +- |
||
29 | net/dns.h | 2 +- |
||
30 | net/nfs.h | 2 +- |
||
31 | net/sntp.h | 2 +- |
||
32 | 5 files changed, 11 insertions(+), 11 deletions(-) |
||
33 | |||
34 | --- a/include/net.h |
||
35 | +++ b/include/net.h |
||
36 | @@ -203,7 +203,7 @@ struct ethernet_hdr { |
||
37 | uchar et_dest[6]; /* Destination node */ |
||
38 | uchar et_src[6]; /* Source node */ |
||
39 | ushort et_protlen; /* Protocol or length */ |
||
40 | -}; |
||
41 | +} __attribute__((packed)); |
||
42 | |||
43 | /* Ethernet header size */ |
||
44 | #define ETHER_HDR_SIZE (sizeof(struct ethernet_hdr)) |
||
45 | @@ -219,7 +219,7 @@ struct e802_hdr { |
||
46 | uchar et_snap2; |
||
47 | uchar et_snap3; |
||
48 | ushort et_prot; /* 802 protocol */ |
||
49 | -}; |
||
50 | +} __attribute__((packed)); |
||
51 | |||
52 | /* 802 + SNAP + ethernet header size */ |
||
53 | #define E802_HDR_SIZE (sizeof(struct e802_hdr)) |
||
54 | @@ -233,7 +233,7 @@ struct vlan_ethernet_hdr { |
||
55 | ushort vet_vlan_type; /* PROT_VLAN */ |
||
56 | ushort vet_tag; /* TAG of VLAN */ |
||
57 | ushort vet_type; /* protocol type */ |
||
58 | -}; |
||
59 | +} __attribute__((packed)); |
||
60 | |||
61 | /* VLAN Ethernet header size */ |
||
62 | #define VLAN_ETHER_HDR_SIZE (sizeof(struct vlan_ethernet_hdr)) |
||
63 | @@ -260,7 +260,7 @@ struct ip_hdr { |
||
64 | ushort ip_sum; /* checksum */ |
||
65 | IPaddr_t ip_src; /* Source IP address */ |
||
66 | IPaddr_t ip_dst; /* Destination IP address */ |
||
67 | -}; |
||
68 | +} __attribute__((packed)); |
||
69 | |||
70 | #define IP_OFFS 0x1fff /* ip offset *= 8 */ |
||
71 | #define IP_FLAGS 0xe000 /* first 3 bits */ |
||
72 | @@ -288,7 +288,7 @@ struct ip_udp_hdr { |
||
73 | ushort udp_dst; /* UDP destination port */ |
||
74 | ushort udp_len; /* Length of UDP packet */ |
||
75 | ushort udp_xsum; /* Checksum */ |
||
76 | -}; |
||
77 | +} __attribute__((packed)); |
||
78 | |||
79 | #define IP_UDP_HDR_SIZE (sizeof(struct ip_udp_hdr)) |
||
80 | #define UDP_HDR_SIZE (IP_UDP_HDR_SIZE - IP_HDR_SIZE) |
||
81 | @@ -327,7 +327,7 @@ struct arp_hdr { |
||
82 | uchar ar_tha[]; /* Target hardware address */ |
||
83 | uchar ar_tpa[]; /* Target protocol address */ |
||
84 | #endif /* 0 */ |
||
85 | -}; |
||
86 | +} __attribute__((packed)); |
||
87 | |||
88 | #define ARP_HDR_SIZE (8+20) /* Size assuming ethernet */ |
||
89 | |||
90 | @@ -362,7 +362,7 @@ struct icmp_hdr { |
||
91 | } frag; |
||
92 | uchar data[0]; |
||
93 | } un; |
||
94 | -}; |
||
95 | +} __attribute__((packed)); |
||
96 | |||
97 | #define ICMP_HDR_SIZE (sizeof(struct icmp_hdr)) |
||
98 | #define IP_ICMP_HDR_SIZE (IP_HDR_SIZE + ICMP_HDR_SIZE) |
||
99 | --- a/net/bootp.h |
||
100 | +++ b/net/bootp.h |
||
101 | @@ -49,7 +49,7 @@ struct Bootp_t { |
||
102 | char bp_sname[64]; /* Server host name */ |
||
103 | char bp_file[128]; /* Boot file name */ |
||
104 | char bp_vend[OPT_FIELD_SIZE]; /* Vendor information */ |
||
105 | -}; |
||
106 | +} __attribute__((packed)); |
||
107 | |||
108 | #define BOOTP_HDR_SIZE sizeof(struct Bootp_t) |
||
109 | |||
110 | --- a/net/dns.h |
||
111 | +++ b/net/dns.h |
||
112 | @@ -29,7 +29,7 @@ struct header { |
||
113 | uint16_t nauth; /* Authority PRs */ |
||
114 | uint16_t nother; /* Other PRs */ |
||
115 | unsigned char data[1]; /* Data, variable length */ |
||
116 | -}; |
||
117 | +} __attribute__((packed)); |
||
118 | |||
119 | extern void DnsStart(void); /* Begin DNS */ |
||
120 | |||
121 | --- a/net/sntp.h |
||
122 | +++ b/net/sntp.h |
||
123 | @@ -51,7 +51,7 @@ struct sntp_pkt_t { |
||
124 | unsigned long long originate_timestamp; |
||
125 | unsigned long long receive_timestamp; |
||
126 | unsigned long long transmit_timestamp; |
||
127 | -}; |
||
128 | +} __attribute__((packed)); |
||
129 | |||
130 | extern void SntpStart(void); /* Begin SNTP */ |
||
131 | |||
132 | --- a/net/nfs.h |
||
133 | +++ b/net/nfs.h |
||
134 | @@ -68,7 +68,7 @@ struct rpc_t { |
||
135 | uint32_t data[19]; |
||
136 | } reply; |
||
137 | } u; |
||
138 | -}; |
||
139 | +} __attribute__((packed)); |
||
140 | extern void NfsStart(void); /* Begin NFS */ |
||
141 | |||
142 |