diff mbox

[ovs-dev,ovn-ipv6,20/26] packets: Add in6_is_lla() function.

Message ID 1468306616-125783-21-git-send-email-jpettit@ovn.org
State Changes Requested
Headers show

Commit Message

Justin Pettit July 12, 2016, 6:56 a.m. UTC
This will have a caller in a future commit.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 lib/packets.h | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ben Pfaff July 13, 2016, 7:56 p.m. UTC | #1
On Mon, Jul 11, 2016 at 11:56:50PM -0700, Justin Pettit wrote:
> This will have a caller in a future commit.
> 
> Signed-off-by: Justin Pettit <jpettit@ovn.org>

I figured out what lla means, but would you mind adding a comment?

> +static inline bool
> +in6_is_lla(struct in6_addr *addr)
> +{

The parentheses after ! aren't needed, do you like them a lot?

> +    return addr->s6_addr32[0] == htonl(0xfe800000) && !(addr->s6_addr32[1]);
> +}

Acked-by: Ben Pfaff <blp@ovn.org>
Ben Pfaff July 13, 2016, 7:57 p.m. UTC | #2
On Mon, Jul 11, 2016 at 11:56:50PM -0700, Justin Pettit wrote:
> This will have a caller in a future commit.
> 
> Signed-off-by: Justin Pettit <jpettit@ovn.org>

> +static inline bool
> +in6_is_lla(struct in6_addr *addr)
> +{
> +    return addr->s6_addr32[0] == htonl(0xfe800000) && !(addr->s6_addr32[1]);
> +}

One more thing: not all implementations have s6_addr32, so we probably
need a fallback.
diff mbox

Patch

diff --git a/lib/packets.h b/lib/packets.h
index 617f058..df6ce4b 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -980,6 +980,12 @@  in6_generate_lla(struct eth_addr ea, struct in6_addr *lla)
     taddr->be16[7] = ea.be16[2];
 }
 
+static inline bool
+in6_is_lla(struct in6_addr *addr)
+{
+    return addr->s6_addr32[0] == htonl(0xfe800000) && !(addr->s6_addr32[1]);
+}
+
 static inline void
 ipv6_multicast_to_ethernet(struct eth_addr *eth, const struct in6_addr *ip6)
 {