diff options
author | Volodymyr Huti <volodymyr.huti@gmail.com> | 2022-10-13 14:20:06 +0300 |
---|---|---|
committer | Volodymyr Huti <volodymyr.huti@gmail.com> | 2022-10-22 15:11:29 +0300 |
commit | 6e5f9980a8a71015a228279e07970621d23c7b35 (patch) | |
tree | 73ae1d6596a175c76a0d24867592a4016c0592c5 /accel-pppd/ipv6 | |
parent | 2b865db72bc2ddc6411950d72f1c23e8ef115b8a (diff) | |
download | accel-ppp-6e5f9980a8a71015a228279e07970621d23c7b35.tar.gz accel-ppp-6e5f9980a8a71015a228279e07970621d23c7b35.zip |
T72: Fix compilations warnings for unaligned variable access
- IPoE/DHCP4: Specify minimal suitable alignment explicitly.
We need to guarantee 2 byte alignment for the `hdr` pointer in
`ip_csum(uint16_t *buf)` calculation
- PPPOE: Suppress false-positive warning for `sockaddr_pppox`.
Similiar issue: https://github.com/kernelslacker/trinity/pull/40
- Introduce tmp variables to avoid alignment issues for SSTP/DHCPv6
For additional details:
https://phabricator.accel-ppp.org/T72
Signed-off-by: Volodymyr Huti <v.huti@vyos.io>
Diffstat (limited to 'accel-pppd/ipv6')
-rw-r--r-- | accel-pppd/ipv6/dhcpv6.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/accel-pppd/ipv6/dhcpv6.c b/accel-pppd/ipv6/dhcpv6.c index cefbcfd8..158771b1 100644 --- a/accel-pppd/ipv6/dhcpv6.c +++ b/accel-pppd/ipv6/dhcpv6.c @@ -244,8 +244,8 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i struct dhcpv6_opt_ia_na *ia_na; struct dhcpv6_opt_ia_addr *ia_addr; struct dhcpv6_opt_ia_prefix *ia_prefix; + struct in6_addr addr, prefix; struct ipv6db_addr_t *a; - struct in6_addr addr; struct ap_session *ses = req->ses; int f = 0, f1, f2 = 0; @@ -282,7 +282,8 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i opt2 = dhcpv6_nested_option_alloc(reply, opt1, D6_OPTION_IAADDR, sizeof(*ia_addr) - sizeof(struct dhcpv6_opt_hdr)); ia_addr = (struct dhcpv6_opt_ia_addr *)opt2->hdr; - build_ip6_addr(a, ses->ipv6->peer_intf_id, &ia_addr->addr); + build_ip6_addr(a, ses->ipv6->peer_intf_id, &addr); + memcpy(&ia_addr->addr, &addr, sizeof(addr)); ia_addr->pref_lifetime = htonl(conf_pref_lifetime); ia_addr->valid_lifetime = htonl(conf_valid_lifetime); @@ -309,8 +310,9 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i list_for_each_entry(opt2, &opt->opt_list, entry) { if (ntohs(opt2->hdr->code) == D6_OPTION_IAADDR) { ia_addr = (struct dhcpv6_opt_ia_addr *)opt2->hdr; + addr = ia_addr->addr; - if (IN6_IS_ADDR_UNSPECIFIED(&ia_addr->addr)) + if (IN6_IS_ADDR_UNSPECIFIED(&addr)) continue; f1 = 0; @@ -389,8 +391,9 @@ static void dhcpv6_send_reply(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, i list_for_each_entry(opt2, &opt->opt_list, entry) { if (ntohs(opt2->hdr->code) == D6_OPTION_IAPREFIX) { ia_prefix = (struct dhcpv6_opt_ia_prefix *)opt2->hdr; + prefix = ia_prefix->prefix; - if (ia_prefix->prefix_len == 0 || IN6_IS_ADDR_UNSPECIFIED(&ia_prefix->prefix)) + if (ia_prefix->prefix_len == 0 || IN6_IS_ADDR_UNSPECIFIED(&prefix)) continue; f1 = 0; @@ -464,7 +467,7 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, struct dhcpv6_opt_ia_addr *ia_addr; struct dhcpv6_opt_ia_prefix *ia_prefix; struct ipv6db_addr_t *a; - struct in6_addr addr; + struct in6_addr addr, prefix; struct ap_session *ses = req->ses; int f = 0, f1, f2 = 0, f3; @@ -488,8 +491,8 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, list_for_each_entry(opt2, &opt->opt_list, entry) { if (ntohs(opt2->hdr->code) == D6_OPTION_IAADDR) { ia_addr = (struct dhcpv6_opt_ia_addr *)opt2->hdr; - - if (IN6_IS_ADDR_UNSPECIFIED(&ia_addr->addr)) + addr = ia_addr->addr; + if (IN6_IS_ADDR_UNSPECIFIED(&addr)) continue; f1 = 0; @@ -550,8 +553,9 @@ static void dhcpv6_send_reply2(struct dhcpv6_packet *req, struct dhcpv6_pd *pd, list_for_each_entry(opt2, &opt->opt_list, entry) { if (ntohs(opt2->hdr->code) == D6_OPTION_IAPREFIX) { ia_prefix = (struct dhcpv6_opt_ia_prefix *)opt2->hdr; + prefix = ia_prefix->prefix; - if (ia_prefix->prefix_len == 0 || IN6_IS_ADDR_UNSPECIFIED(&ia_prefix->prefix)) + if (ia_prefix->prefix_len == 0 || IN6_IS_ADDR_UNSPECIFIED(&prefix)) continue; f1 = 0; |