mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 22:35:15 +00:00
odp: Use struct in6_addr for IPv6 addresses.
Code is simplified when the ODP keys use the same type as the struct flow for the IPv6 addresses. As the change is facilitated by extract-odp-netlink-h, this change only affects the userspace. We already do the same for the ethernet addresses. Signed-off-by: Jarno Rajahalme <jarno@ovn.org> Acked-by: Ben Pfaff <blp@ovn.org>
This commit is contained in:
@@ -960,7 +960,8 @@ packet_rh_present(struct dp_packet *packet, uint8_t *nexthdr)
|
||||
|
||||
static void
|
||||
packet_update_csum128(struct dp_packet *packet, uint8_t proto,
|
||||
ovs_16aligned_be32 addr[4], const ovs_be32 new_addr[4])
|
||||
ovs_16aligned_be32 addr[4],
|
||||
const struct in6_addr *new_addr)
|
||||
{
|
||||
size_t l4_size = dp_packet_l4_size(packet);
|
||||
|
||||
@@ -987,7 +988,8 @@ packet_update_csum128(struct dp_packet *packet, uint8_t proto,
|
||||
|
||||
static void
|
||||
packet_set_ipv6_addr(struct dp_packet *packet, uint8_t proto,
|
||||
ovs_16aligned_be32 addr[4], const ovs_be32 new_addr[4],
|
||||
ovs_16aligned_be32 addr[4],
|
||||
const struct in6_addr *new_addr,
|
||||
bool recalculate_csum)
|
||||
{
|
||||
if (recalculate_csum) {
|
||||
@@ -1052,8 +1054,8 @@ packet_set_ipv4(struct dp_packet *packet, ovs_be32 src, ovs_be32 dst,
|
||||
* appropriate. 'packet' must contain a valid IPv6 packet with correctly
|
||||
* populated l[34] offsets. */
|
||||
void
|
||||
packet_set_ipv6(struct dp_packet *packet, const ovs_be32 src[4],
|
||||
const ovs_be32 dst[4], uint8_t key_tc, ovs_be32 key_fl,
|
||||
packet_set_ipv6(struct dp_packet *packet, const struct in6_addr *src,
|
||||
const struct in6_addr *dst, uint8_t key_tc, ovs_be32 key_fl,
|
||||
uint8_t key_hl)
|
||||
{
|
||||
struct ovs_16aligned_ip6_hdr *nh = dp_packet_l3(packet);
|
||||
@@ -1158,7 +1160,7 @@ packet_set_icmp(struct dp_packet *packet, uint8_t type, uint8_t code)
|
||||
}
|
||||
|
||||
void
|
||||
packet_set_nd(struct dp_packet *packet, const ovs_be32 target[4],
|
||||
packet_set_nd(struct dp_packet *packet, const struct in6_addr *target,
|
||||
const struct eth_addr sll, const struct eth_addr tll)
|
||||
{
|
||||
struct ovs_nd_msg *ns;
|
||||
@@ -1174,9 +1176,8 @@ packet_set_nd(struct dp_packet *packet, const ovs_be32 target[4],
|
||||
bytes_remain -= sizeof(*ns);
|
||||
|
||||
if (memcmp(&ns->target, target, sizeof(ovs_be32[4]))) {
|
||||
packet_set_ipv6_addr(packet, IPPROTO_ICMPV6,
|
||||
ns->target.be32,
|
||||
target, true);
|
||||
packet_set_ipv6_addr(packet, IPPROTO_ICMPV6, ns->target.be32, target,
|
||||
true);
|
||||
}
|
||||
|
||||
while (bytes_remain >= ND_OPT_LEN && nd_opt->nd_opt_len != 0) {
|
||||
@@ -1352,19 +1353,13 @@ compose_ipv6(struct dp_packet *packet, uint8_t proto,
|
||||
struct ip6_hdr *nh;
|
||||
void *data;
|
||||
|
||||
/* Copy 'src' and 'dst' to temporary buffers to prevent misaligned
|
||||
* accesses. */
|
||||
ovs_be32 sbuf[4], dbuf[4];
|
||||
memcpy(sbuf, src, sizeof sbuf);
|
||||
memcpy(dbuf, dst, sizeof dbuf);
|
||||
|
||||
nh = dp_packet_l3(packet);
|
||||
nh->ip6_vfc = 0x60;
|
||||
nh->ip6_nxt = proto;
|
||||
nh->ip6_plen = htons(size);
|
||||
data = dp_packet_put_zeros(packet, size);
|
||||
dp_packet_set_l4(packet, data);
|
||||
packet_set_ipv6(packet, sbuf, dbuf, key_tc, key_fl, key_hl);
|
||||
packet_set_ipv6(packet, src, dst, key_tc, key_fl, key_hl);
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -1394,10 +1389,7 @@ compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
|
||||
nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
|
||||
nd_opt->nd_opt_len = 1;
|
||||
|
||||
/* Copy target address to temp buffer to prevent misaligned access. */
|
||||
ovs_be32 tbuf[4];
|
||||
memcpy(tbuf, ipv6_dst->s6_addr, sizeof tbuf);
|
||||
packet_set_nd(b, tbuf, eth_src, eth_addr_zero);
|
||||
packet_set_nd(b, ipv6_dst, eth_src, eth_addr_zero);
|
||||
|
||||
ns->icmph.icmp6_cksum = 0;
|
||||
icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
|
||||
@@ -1428,10 +1420,7 @@ compose_nd_na(struct dp_packet *b,
|
||||
nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
|
||||
nd_opt->nd_opt_len = 1;
|
||||
|
||||
/* Copy target address to temp buffer to prevent misaligned access. */
|
||||
ovs_be32 tbuf[4];
|
||||
memcpy(tbuf, ipv6_src->s6_addr, sizeof tbuf);
|
||||
packet_set_nd(b, tbuf, eth_addr_zero, eth_src);
|
||||
packet_set_nd(b, ipv6_src, eth_addr_zero, eth_src);
|
||||
|
||||
na->icmph.icmp6_cksum = 0;
|
||||
icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
|
||||
|
Reference in New Issue
Block a user