{
        const void *a = skb_metadata_end(skb_a);
        const void *b = skb_metadata_end(skb_b);
-       /* Using more efficient varaiant than plain call to memcmp(). */
-#if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64
        u64 diffs = 0;
 
+       if (!IS_ENABLED(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) ||
+           BITS_PER_LONG != 64)
+               goto slow;
+
+       /* Using more efficient variant than plain call to memcmp(). */
        switch (meta_len) {
 #define __it(x, op) (x -= sizeof(u##op))
 #define __it_diff(a, b, op) (*(u##op *)__it(a, op)) ^ (*(u##op *)__it(b, op))
                fallthrough;
        case  4: diffs |= __it_diff(a, b, 32);
                break;
+       default:
+slow:
+               return memcmp(a - meta_len, b - meta_len, meta_len);
        }
        return diffs;
-#else
-       return memcmp(a - meta_len, b - meta_len, meta_len);
-#endif
 }
 
 static inline bool skb_metadata_differs(const struct sk_buff *skb_a,
 
 
 static inline bool xdp_metalen_invalid(unsigned long metalen)
 {
-       return (metalen & (sizeof(__u32) - 1)) || (metalen > 32);
+       unsigned long meta_max;
+
+       meta_max = type_max(typeof_member(struct skb_shared_info, meta_len));
+       BUILD_BUG_ON(!__builtin_constant_p(meta_max));
+
+       return !IS_ALIGNED(metalen, sizeof(u32)) || metalen > meta_max;
 }
 
 struct xdp_attachment_info {