summaryrefslogtreecommitdiff
path: root/include/sparse
diff options
context:
space:
mode:
authorBen Pfaff <blp@ovn.org>2019-04-23 16:42:32 -0700
committerBen Pfaff <blp@ovn.org>2019-04-24 08:37:08 -0700
commit0cdd5b13de91b989dc92246e20ee6d528417df97 (patch)
tree90658b62a4d3eaa05641fc7ac1c9bb86ea409f78 /include/sparse
parent46124c18b093bee851f30c9fc938c1ff8c2c75ee (diff)
downloadopenvswitch-0cdd5b13de91b989dc92246e20ee6d528417df97.tar.gz
sparse: Configure target operating system and fix fallout.
cgcc, the "sparse" wrapper that OVS uses, can be told the host architecture or the host OS or both. Until now, OVS has told it the host architecture because it is fairly common that it doesn't guess it automatically. Until now, OS has not told it the host OS, assuming that it would get it right. However, it doesn't--if you tell it the host OS or the host architecture, it doesn't really have a default for the other. This means that on Linux (presumably the only OS where sparse works properly for OVS), it was not defining __linux__, which caused some weird behavior. This commit adds a flag to the cgcc invocation to make it define __linux__ on Linux, and it fixes some errors that this would otherwise cause. Acked-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'include/sparse')
-rw-r--r--include/sparse/automake.mk1
-rw-r--r--include/sparse/linux/if_packet.h30
2 files changed, 31 insertions, 0 deletions
diff --git a/include/sparse/automake.mk b/include/sparse/automake.mk
index 4c7b17783..8d96d0346 100644
--- a/include/sparse/automake.mk
+++ b/include/sparse/automake.mk
@@ -27,4 +27,5 @@ noinst_HEADERS += \
include/sparse/sys/types.h \
include/sparse/sys/wait.h \
include/sparse/threads.h \
+ include/sparse/linux/if_packet.h \
include/sparse/linux/tc_act/tc_pedit.h
diff --git a/include/sparse/linux/if_packet.h b/include/sparse/linux/if_packet.h
new file mode 100644
index 000000000..5ff6d4730
--- /dev/null
+++ b/include/sparse/linux/if_packet.h
@@ -0,0 +1,30 @@
+#ifndef FIX_LINUX_IF_PACKET_H
+#define FIX_LINUX_IF_PACKET_H
+
+#ifndef __CHECKER__
+#error "Use this header only with sparse. It is not a correct implementation."
+#endif
+
+#include_next <linux/if_packet.h>
+
+/* Fix endianness of 'spkt_protocol' and 'sll_protocol' members. */
+
+#define sockaddr_pkt rpl_sockaddr_pkt
+struct sockaddr_pkt {
+ unsigned short spkt_family;
+ unsigned char spkt_device[14];
+ ovs_be16 spkt_protocol;
+};
+
+#define sockaddr_ll rpl_sockaddr_ll
+struct sockaddr_ll {
+ unsigned short sll_family;
+ ovs_be16 sll_protocol;
+ int sll_ifindex;
+ unsigned short sll_hatype;
+ unsigned char sll_pkttype;
+ unsigned char sll_halen;
+ unsigned char sll_addr[8];
+};
+
+#endif