[ovs-dev] [PATCH v4 2/6] lib: rename ovs_nd_opt to ovs_nd_lla_opt
nusiddiq at redhat.com
nusiddiq at redhat.com
Thu Mar 23 06:04:18 UTC 2017
From: Zong Kai LI <zealokii at gmail.com>
Since ovs_nd_mtu_opt and ovs_nd_prefix_opt is introducted, rename
ovs_nd_opt to ovs_nd_lla_opt to specify it's Source/Target Link-layer
Address Option.
Signed-off-by: Zongkai LI <zealokii at gmail.com>
Signed-off-by: Numan Siddique <nusiddiq at redhat.com>
---
lib/flow.c | 38 ++++++++++++++---------------
lib/odp-execute.c | 22 ++++++++---------
lib/packets.c | 72 +++++++++++++++++++++++++++----------------------------
lib/packets.h | 19 +++++++--------
4 files changed, 75 insertions(+), 76 deletions(-)
diff --git a/lib/flow.c b/lib/flow.c
index f628526..ca4d96e 100644
--- a/lib/flow.c
+++ b/lib/flow.c
@@ -414,9 +414,9 @@ parse_icmpv6(const void **datap, size_t *sizep, const struct icmp6_hdr *icmp,
while (*sizep >= 8) {
/* The minimum size of an option is 8 bytes, which also is
- * the size of Ethernet link-layer options. */
- const struct ovs_nd_opt *nd_opt = *datap;
- int opt_len = nd_opt->nd_opt_len * ND_OPT_LEN;
+ * the size of Ethernet link-layer options. */
+ const struct ovs_nd_lla_opt *lla_opt = *datap;
+ int opt_len = lla_opt->len * ND_LLA_OPT_LEN;
if (!opt_len || opt_len > *sizep) {
return true;
@@ -425,19 +425,19 @@ parse_icmpv6(const void **datap, size_t *sizep, const struct icmp6_hdr *icmp,
/* Store the link layer address if the appropriate option is
* provided. It is considered an error if the same link
* layer option is specified twice. */
- if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LINKADDR
+ if (lla_opt->type == ND_OPT_SOURCE_LINKADDR
&& opt_len == 8) {
if (OVS_LIKELY(eth_addr_is_zero(arp_buf[0]))) {
- arp_buf[0] = nd_opt->nd_opt_mac;
+ arp_buf[0] = lla_opt->mac;
} else {
- goto invalid;
+ goto invalid;
}
- } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LINKADDR
- && opt_len == 8) {
+ } else if (lla_opt->type == ND_OPT_TARGET_LINKADDR
+ && opt_len == 8) {
if (OVS_LIKELY(eth_addr_is_zero(arp_buf[1]))) {
- arp_buf[1] = nd_opt->nd_opt_mac;
+ arp_buf[1] = lla_opt->mac;
} else {
- goto invalid;
+ goto invalid;
}
}
@@ -2469,7 +2469,7 @@ flow_compose_l4(struct dp_packet *p, const struct flow *flow)
(icmp->icmp6_type == ND_NEIGHBOR_SOLICIT ||
icmp->icmp6_type == ND_NEIGHBOR_ADVERT)) {
struct in6_addr *nd_target;
- struct ovs_nd_opt *nd_opt;
+ struct ovs_nd_lla_opt *lla_opt;
l4_len += sizeof *nd_target;
nd_target = dp_packet_put_zeros(p, sizeof *nd_target);
@@ -2477,17 +2477,17 @@ flow_compose_l4(struct dp_packet *p, const struct flow *flow)
if (!eth_addr_is_zero(flow->arp_sha)) {
l4_len += 8;
- nd_opt = dp_packet_put_zeros(p, 8);
- nd_opt->nd_opt_len = 1;
- nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
- nd_opt->nd_opt_mac = flow->arp_sha;
+ lla_opt = dp_packet_put_zeros(p, 8);
+ lla_opt->len = 1;
+ lla_opt->type = ND_OPT_SOURCE_LINKADDR;
+ lla_opt->mac = flow->arp_sha;
}
if (!eth_addr_is_zero(flow->arp_tha)) {
l4_len += 8;
- nd_opt = dp_packet_put_zeros(p, 8);
- nd_opt->nd_opt_len = 1;
- nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
- nd_opt->nd_opt_mac = flow->arp_tha;
+ lla_opt = dp_packet_put_zeros(p, 8);
+ lla_opt->len = 1;
+ lla_opt->type = ND_OPT_TARGET_LINKADDR;
+ lla_opt->mac = flow->arp_tha;
}
}
}
diff --git a/lib/odp-execute.c b/lib/odp-execute.c
index b03cbd4..dbba4a0 100644
--- a/lib/odp-execute.c
+++ b/lib/odp-execute.c
@@ -233,33 +233,33 @@ odp_set_nd(struct dp_packet *packet, const struct ovs_key_nd *key,
const struct ovs_key_nd *mask)
{
const struct ovs_nd_msg *ns = dp_packet_l4(packet);
- const struct ovs_nd_opt *nd_opt = dp_packet_get_nd_payload(packet);
+ const struct ovs_nd_lla_opt *lla_opt = dp_packet_get_nd_payload(packet);
- if (OVS_LIKELY(ns && nd_opt)) {
+ if (OVS_LIKELY(ns && lla_opt)) {
int bytes_remain = dp_packet_l4_size(packet) - sizeof(*ns);
struct in6_addr tgt_buf;
struct eth_addr sll_buf = eth_addr_zero;
struct eth_addr tll_buf = eth_addr_zero;
- while (bytes_remain >= ND_OPT_LEN && nd_opt->nd_opt_len != 0) {
- if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LINKADDR
- && nd_opt->nd_opt_len == 1) {
- sll_buf = nd_opt->nd_opt_mac;
+ while (bytes_remain >= ND_LLA_OPT_LEN && lla_opt->len != 0) {
+ if (lla_opt->type == ND_OPT_SOURCE_LINKADDR
+ && lla_opt->len == 1) {
+ sll_buf = lla_opt->mac;
ether_addr_copy_masked(&sll_buf, key->nd_sll, mask->nd_sll);
/* A packet can only contain one SLL or TLL option */
break;
- } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LINKADDR
- && nd_opt->nd_opt_len == 1) {
- tll_buf = nd_opt->nd_opt_mac;
+ } else if (lla_opt->type == ND_OPT_TARGET_LINKADDR
+ && lla_opt->len == 1) {
+ tll_buf = lla_opt->mac;
ether_addr_copy_masked(&tll_buf, key->nd_tll, mask->nd_tll);
/* A packet can only contain one SLL or TLL option */
break;
}
- nd_opt += nd_opt->nd_opt_len;
- bytes_remain -= nd_opt->nd_opt_len * ND_OPT_LEN;
+ lla_opt += lla_opt->len;
+ bytes_remain -= lla_opt->len * ND_LLA_OPT_LEN;
}
packet_set_nd(packet,
diff --git a/lib/packets.c b/lib/packets.c
index dbe5105..e9d8f00 100644
--- a/lib/packets.c
+++ b/lib/packets.c
@@ -1165,7 +1165,7 @@ 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;
- struct ovs_nd_opt *nd_opt;
+ struct ovs_nd_lla_opt *lla_opt;
int bytes_remain = dp_packet_l4_size(packet);
if (OVS_UNLIKELY(bytes_remain < sizeof(*ns))) {
@@ -1173,7 +1173,7 @@ packet_set_nd(struct dp_packet *packet, const struct in6_addr *target,
}
ns = dp_packet_l4(packet);
- nd_opt = &ns->options[0];
+ lla_opt = &ns->options[0];
bytes_remain -= sizeof(*ns);
if (memcmp(&ns->target, target, sizeof(ovs_be32[4]))) {
@@ -1181,33 +1181,33 @@ packet_set_nd(struct dp_packet *packet, const struct in6_addr *target,
true);
}
- while (bytes_remain >= ND_OPT_LEN && nd_opt->nd_opt_len != 0) {
- if (nd_opt->nd_opt_type == ND_OPT_SOURCE_LINKADDR
- && nd_opt->nd_opt_len == 1) {
- if (!eth_addr_equals(nd_opt->nd_opt_mac, sll)) {
+ while (bytes_remain >= ND_LLA_OPT_LEN && lla_opt->len != 0) {
+ if (lla_opt->type == ND_OPT_SOURCE_LINKADDR
+ && lla_opt->len == 1) {
+ if (!eth_addr_equals(lla_opt->mac, sll)) {
ovs_be16 *csum = &(ns->icmph.icmp6_cksum);
- *csum = recalc_csum48(*csum, nd_opt->nd_opt_mac, sll);
- nd_opt->nd_opt_mac = sll;
+ *csum = recalc_csum48(*csum, lla_opt->mac, sll);
+ lla_opt->mac = sll;
}
/* A packet can only contain one SLL or TLL option */
break;
- } else if (nd_opt->nd_opt_type == ND_OPT_TARGET_LINKADDR
- && nd_opt->nd_opt_len == 1) {
- if (!eth_addr_equals(nd_opt->nd_opt_mac, tll)) {
+ } else if (lla_opt->type == ND_OPT_TARGET_LINKADDR
+ && lla_opt->len == 1) {
+ if (!eth_addr_equals(lla_opt->mac, tll)) {
ovs_be16 *csum = &(ns->icmph.icmp6_cksum);
- *csum = recalc_csum48(*csum, nd_opt->nd_opt_mac, tll);
- nd_opt->nd_opt_mac = tll;
+ *csum = recalc_csum48(*csum, lla_opt->mac, tll);
+ lla_opt->mac = tll;
}
/* A packet can only contain one SLL or TLL option */
break;
}
- nd_opt += nd_opt->nd_opt_len;
- bytes_remain -= nd_opt->nd_opt_len * ND_OPT_LEN;
+ lla_opt += lla_opt->len;
+ bytes_remain -= lla_opt->len * ND_LLA_OPT_LEN;
}
}
@@ -1372,7 +1372,7 @@ compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
struct in6_addr sn_addr;
struct eth_addr eth_dst;
struct ovs_nd_msg *ns;
- struct ovs_nd_opt *nd_opt;
+ struct ovs_nd_lla_opt *lla_opt;
uint32_t icmp_csum;
in6_addr_solicited_node(&sn_addr, ipv6_dst);
@@ -1380,22 +1380,22 @@ compose_nd_ns(struct dp_packet *b, const struct eth_addr eth_src,
eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
ns = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, &sn_addr,
- 0, 0, 255, ND_MSG_LEN + ND_OPT_LEN);
+ 0, 0, 255, ND_MSG_LEN + ND_LLA_OPT_LEN);
ns->icmph.icmp6_type = ND_NEIGHBOR_SOLICIT;
ns->icmph.icmp6_code = 0;
put_16aligned_be32(&ns->rso_flags, htonl(0));
- nd_opt = &ns->options[0];
- nd_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
- nd_opt->nd_opt_len = 1;
+ lla_opt = &ns->options[0];
+ lla_opt->type = ND_OPT_SOURCE_LINKADDR;
+ lla_opt->len = 1;
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));
- ns->icmph.icmp6_cksum = csum_finish(csum_continue(icmp_csum, ns,
- ND_MSG_LEN + ND_OPT_LEN));
+ ns->icmph.icmp6_cksum = csum_finish(
+ csum_continue(icmp_csum, ns, ND_MSG_LEN + ND_LLA_OPT_LEN));
}
/* Compose an IPv6 Neighbor Discovery Neighbor Advertisement message. */
@@ -1406,27 +1406,27 @@ compose_nd_na(struct dp_packet *b,
ovs_be32 rso_flags)
{
struct ovs_nd_msg *na;
- struct ovs_nd_opt *nd_opt;
+ struct ovs_nd_lla_opt *lla_opt;
uint32_t icmp_csum;
eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
na = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, ipv6_dst,
- 0, 0, 255, ND_MSG_LEN + ND_OPT_LEN);
+ 0, 0, 255, ND_MSG_LEN + ND_LLA_OPT_LEN);
na->icmph.icmp6_type = ND_NEIGHBOR_ADVERT;
na->icmph.icmp6_code = 0;
put_16aligned_be32(&na->rso_flags, rso_flags);
- nd_opt = &na->options[0];
- nd_opt->nd_opt_type = ND_OPT_TARGET_LINKADDR;
- nd_opt->nd_opt_len = 1;
+ lla_opt = &na->options[0];
+ lla_opt->type = ND_OPT_TARGET_LINKADDR;
+ lla_opt->len = 1;
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));
- na->icmph.icmp6_cksum = csum_finish(csum_continue(icmp_csum, na,
- ND_MSG_LEN + ND_OPT_LEN));
+ na->icmph.icmp6_cksum = csum_finish(csum_continue(
+ icmp_csum, na, ND_MSG_LEN + ND_LLA_OPT_LEN));
}
/* Compose an IPv6 Neighbor Discovery Router Advertisement message with
@@ -1444,8 +1444,8 @@ compose_nd_ra_with_sll_mtu_opts(struct dp_packet *b,
ovs_be32 retrans_timer, ovs_be32 mtu)
{
struct ovs_ra_msg *ra;
+ struct ovs_nd_lla_opt *lla_opt;
struct ovs_nd_mtu_opt *mtu_opt;
- struct ovs_nd_opt *lla_opt;
uint32_t icmp_csum;
/* Don't compose Router Advertisement packet with MTU Option if mtu
@@ -1455,7 +1455,7 @@ compose_nd_ra_with_sll_mtu_opts(struct dp_packet *b,
eth_compose(b, eth_dst, eth_src, ETH_TYPE_IPV6, IPV6_HEADER_LEN);
ra = compose_ipv6(b, IPPROTO_ICMPV6, ipv6_src, ipv6_dst, 0, 0, 255,
- RA_MSG_LEN + ND_OPT_LEN + mtu_opt_len);
+ RA_MSG_LEN + ND_LLA_OPT_LEN + mtu_opt_len);
ra->icmph.icmp6_type = ND_ROUTER_ADVERT;
ra->icmph.icmp6_code = 0;
@@ -1466,12 +1466,12 @@ compose_nd_ra_with_sll_mtu_opts(struct dp_packet *b,
ra->retrans_timer = retrans_timer;
lla_opt = &ra->options[0];
- lla_opt->nd_opt_type = ND_OPT_SOURCE_LINKADDR;
- lla_opt->nd_opt_len = 1;
- lla_opt->nd_opt_mac = eth_src;
+ lla_opt->type = ND_OPT_SOURCE_LINKADDR;
+ lla_opt->len = 1;
+ lla_opt->mac = eth_src;
if (with_mtu) {
- /* ovs_nd_mtu_opt has the same size with ovs_nd_opt. */
+ /* ovs_nd_mtu_opt has the same size with ovs_nd_lla_opt. */
mtu_opt = (struct ovs_nd_mtu_opt *)(lla_opt + 1);
mtu_opt->type = ND_OPT_MTU;
mtu_opt->len = 1;
@@ -1482,7 +1482,7 @@ compose_nd_ra_with_sll_mtu_opts(struct dp_packet *b,
ra->icmph.icmp6_cksum = 0;
icmp_csum = packet_csum_pseudoheader6(dp_packet_l3(b));
ra->icmph.icmp6_cksum = csum_finish(csum_continue(
- icmp_csum, ra, RA_MSG_LEN + ND_OPT_LEN + mtu_opt_len));
+ icmp_csum, ra, RA_MSG_LEN + ND_LLA_OPT_LEN + mtu_opt_len));
}
/* Append an IPv6 Neighbor Discovery Prefix Information option to a
diff --git a/lib/packets.h b/lib/packets.h
index b285185..7948793 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -848,15 +848,14 @@ uint32_t packet_csum_pseudoheader6(const struct ovs_16aligned_ip6_hdr *);
uint16_t packet_csum_upperlayer6(const struct ovs_16aligned_ip6_hdr *,
const void *, uint8_t, uint16_t);
-/* Neighbor Discovery option field.
- * ND options are always a multiple of 8 bytes in size. */
-#define ND_OPT_LEN 8
-struct ovs_nd_opt {
- uint8_t nd_opt_type; /* Values defined in icmp6.h */
- uint8_t nd_opt_len; /* in units of 8 octets (the size of this struct) */
- struct eth_addr nd_opt_mac; /* Ethernet address in the case of SLL or TLL options */
+/* Neighbor Discovery option: Source/Target Link-layer Address. */
+#define ND_LLA_OPT_LEN 8
+struct ovs_nd_lla_opt {
+ uint8_t type; /* Values defined in icmp6.h */
+ uint8_t len; /* in units of 8 octets (the size of this struct) */
+ struct eth_addr mac; /* Ethernet address in the case of SLL or TLL options */
};
-BUILD_ASSERT_DECL(ND_OPT_LEN == sizeof(struct ovs_nd_opt));
+BUILD_ASSERT_DECL(ND_LLA_OPT_LEN == sizeof(struct ovs_nd_lla_opt));
/* Neighbor Discovery option: Prefix Information. */
#define ND_PREFIX_OPT_LEN 32
@@ -892,7 +891,7 @@ struct ovs_nd_msg {
struct icmp6_header icmph;
ovs_16aligned_be32 rso_flags;
union ovs_16aligned_in6_addr target;
- struct ovs_nd_opt options[0];
+ struct ovs_nd_lla_opt options[0];
};
BUILD_ASSERT_DECL(ND_MSG_LEN == sizeof(struct ovs_nd_msg));
@@ -909,7 +908,7 @@ struct ovs_ra_msg {
ovs_be16 router_lifetime;
ovs_be32 reachable_time;
ovs_be32 retrans_timer;
- struct ovs_nd_opt options[0];
+ struct ovs_nd_lla_opt options[0];
};
BUILD_ASSERT_DECL(RA_MSG_LEN == sizeof(struct ovs_ra_msg));
--
2.9.3
More information about the dev
mailing list