diff --git a/hlist.h b/hlist.h
index 100fca165b2cb496af800ed0e72a1d221cf23173..b68343c798be9651df8dc84c66df112284debe14 100644
--- a/hlist.h
+++ b/hlist.h
@@ -14,6 +14,18 @@
 #ifndef _HLIST_H
 #define _HLIST_H
 
+#ifndef offsetof
+#define offsetof(type, member) ((size_t) &((type *)0)->member)
+#endif
+
+#ifndef container_of
+#define container_of(ptr, type, member)					\
+({									\
+	const __typeof__(((type *) NULL)->member) *__mptr = (ptr);	\
+	(type *) ((char *) __mptr - offsetof(type, member));		\
+})
+#endif
+
 struct hlist_node {
 	struct hlist_node *next;
 };
diff --git a/utils.h b/utils.h
index 0cfb836ee7c308f8b3f8fbd77a5e4b3779294139..c14e77047356f295d4829173c915279c82d58770 100644
--- a/utils.h
+++ b/utils.h
@@ -136,6 +136,14 @@ extern int get_ifoperstatus(const char *ifname, ifopstatus_t *opstatus);
 #define offsetof(type, member) ((size_t) &((type *)0)->member)
 #endif
 
+#ifndef container_of
+#define container_of(ptr, type, member)					\
+({									\
+	const __typeof__(((type *) NULL)->member) *__mptr = (ptr);	\
+	(type *) ((char *) __mptr - offsetof(type, member));		\
+})
+#endif
+
 #ifndef bit
 #define bit(_n)	(1 << (_n))
 #endif