]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/net/netfilter/nf_tables_core.h
Merge branch 'for-3.15' of git://linux-nfs.org/~bfields/linux
[karo-tx-linux.git] / include / net / netfilter / nf_tables_core.h
index cf2b7ae2b9d82b11cfa7a810130187e2c763881a..a75fc8e27cd698483232a3f3a379efc76308a905 100644 (file)
@@ -13,6 +13,16 @@ struct nft_cmp_fast_expr {
        u8                      len;
 };
 
+/* Calculate the mask for the nft_cmp_fast expression. On big endian the
+ * mask needs to include the *upper* bytes when interpreting that data as
+ * something smaller than the full u32, therefore a cpu_to_le32 is done.
+ */
+static inline u32 nft_cmp_fast_mask(unsigned int len)
+{
+       return cpu_to_le32(~0U >> (FIELD_SIZEOF(struct nft_cmp_fast_expr,
+                                               data) * BITS_PER_BYTE - len));
+}
+
 extern const struct nft_expr_ops nft_cmp_fast_ops;
 
 int nft_cmp_module_init(void);