vlib: prevent some signals from being executed on workers
[vpp.git] / src / plugins / nat / CMakeLists.txt
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 set(CMAKE_VERBOSE_MAKEFILE ON)
15
16 add_vpp_library(nat
17   SOURCES
18   lib/ipfix_logging.c
19   lib/nat_syslog.c
20   lib/alloc.c
21   lib/lib.c
22
23   INSTALL_HEADERS
24   lib/ipfix_logging.h
25   lib/nat_syslog.h
26   lib/alloc.h
27   lib/lib.h
28 )
29
30 add_vpp_plugin(nat
31   SOURCES
32   nat44-ed/nat44_ed.c
33   nat44-ed/nat44_ed_api.c
34   nat44-ed/nat44_ed_in2out.c
35   nat44-ed/nat44_ed_out2in.c
36   nat44-ed/nat44_ed_cli.c
37   nat44-ed/nat44_ed_format.c
38   nat44-ed/nat44_ed_affinity.c
39   nat44-ed/nat44_ed_handoff.c
40   nat44-ed/nat44_ed_classify.c
41
42   MULTIARCH_SOURCES
43   nat44-ed/nat44_ed_in2out.c
44   nat44-ed/nat44_ed_out2in.c
45   nat44-ed/nat44_ed_handoff.c
46   nat44-ed/nat44_ed_classify.c
47
48   API_FILES
49   nat44-ed/nat44_ed.api
50   lib/nat_types.api
51
52   LINK_LIBRARIES nat
53 )
54
55 add_vpp_plugin(nat44_ei
56   SOURCES
57   nat44-ei/nat44_ei.c
58   nat44-ei/nat44_ei_ha.c
59   nat44-ei/nat44_ei_cli.c
60   nat44-ei/nat44_ei_api.c
61   nat44-ei/nat44_ei_dpo.c
62   nat44-ei/nat44_ei_in2out.c
63   nat44-ei/nat44_ei_out2in.c
64   nat44-ei/nat44_ei_handoff.c
65
66   MULTIARCH_SOURCES
67   nat44-ei/nat44_ei_in2out.c
68   nat44-ei/nat44_ei_out2in.c
69
70   API_FILES
71   nat44-ei/nat44_ei.api
72   lib/nat_types.api
73
74   LINK_LIBRARIES nat
75 )
76
77 add_vpp_plugin(dslite
78   SOURCES
79   dslite/dslite_api.c
80   dslite/dslite_dpo.c
81   dslite/dslite.c
82   dslite/dslite_in2out.c
83   dslite/dslite_out2in.c
84   dslite/dslite_cli.c
85   dslite/dslite_ce_encap.c
86   dslite/dslite_ce_decap.c
87
88   MULTIARCH_SOURCES
89   dslite/dslite_ce_decap.c
90   dslite/dslite_ce_encap.c
91   dslite/dslite_in2out.c
92   dslite/dslite_out2in.c
93
94   API_FILES
95   dslite/dslite.api
96
97   LINK_LIBRARIES nat
98 )
99
100 add_vpp_plugin(nat66
101   SOURCES
102   nat66/nat66.c
103   nat66/nat66_cli.c
104   nat66/nat66_api.c
105   nat66/nat66_in2out.c
106   nat66/nat66_out2in.c
107
108   MULTIARCH_SOURCES
109   nat66/nat66_in2out.c
110   nat66/nat66_out2in.c
111
112   API_FILES
113   nat66/nat66.api
114   lib/nat_types.api
115
116   LINK_LIBRARIES nat
117 )
118
119 add_vpp_plugin(det44
120   SOURCES
121   det44/det44.c
122   det44/det44_cli.c
123   det44/det44_api.c
124   det44/det44_in2out.c
125   det44/det44_out2in.c
126
127   MULTIARCH_SOURCES
128   det44/det44_in2out.c
129   det44/det44_out2in.c
130
131   API_FILES
132   det44/det44.api
133   lib/nat_types.api
134
135   LINK_LIBRARIES nat
136 )
137
138 add_vpp_plugin(nat64
139   SOURCES
140   nat64/nat64.c
141   nat64/nat64_db.c
142   nat64/nat64_cli.c
143   nat64/nat64_api.c
144   nat64/nat64_in2out.c
145   nat64/nat64_out2in.c
146
147   MULTIARCH_SOURCES
148   nat64/nat64_in2out.c
149   nat64/nat64_out2in.c
150
151   API_FILES
152   nat64/nat64.api
153   lib/nat_types.api
154
155   LINK_LIBRARIES nat
156 )
157
158 add_vpp_plugin(pnat
159   SOURCES
160   pnat/pnat.c
161   pnat/pnat_node.c
162   pnat/pnat_cli.c
163   pnat/pnat_api.c
164
165   MULTIARCH_SOURCES
166   pnat/pnat_node.c
167
168   API_FILES
169   pnat/pnat.api
170 )
171
172 # Unit tests
173 set (PACKET_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/test_packets.h)
174 set (PACKET_DEFS
175   ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/packets.def
176   ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/missing_rule.def)
177 set (PACKET_TESTGET ${CMAKE_CURRENT_SOURCE_DIR}/pnat/tests/test_genpackets.py)
178
179 add_vpp_executable(test_pnat
180   SOURCES
181   pnat/tests/pnat_test.c
182   pnat/pnat_node.c
183   pnat/pnat.c
184   ../../vnet/ip/ip_checksum.c
185
186   LINK_LIBRARIES vppinfra vlib
187   NO_INSTALL
188 )
189
190 add_custom_target(test_pnat-generate
191   COMMAND ${PACKET_TESTGET} ${PACKET_DEFS} > ${PACKET_HEADER}
192   COMMENT "Generating packet test definitions ${PACKET_DEFS}"
193 )
194
195 add_custom_target(test_pnat-run
196   COMMAND test_pnat
197   DEPENDS test_pnat
198 )
199
200 if(VPP_BUILD_TESTS_WITH_COVERAGE)
201   set(TARGET_NAME test_pnat)
202   set(COV_SOURCES ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat.c ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.h ${CMAKE_SOURCE_DIR}/plugins/nat/pnat/pnat_node.c)
203
204   message("Building with llvm Code Coverage Tools ${TARGET_NAME}")
205   target_compile_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
206   target_link_options(${TARGET_NAME} PRIVATE -fprofile-instr-generate -fcoverage-mapping)
207   target_compile_options(${TARGET_NAME} PRIVATE -fsanitize=address)
208   target_link_options(${TARGET_NAME} PRIVATE -fsanitize=address)
209
210   # llvm-cov
211   add_custom_target(${TARGET_NAME}-ccov-preprocessing
212     COMMAND LLVM_PROFILE_FILE=${TARGET_NAME}.profraw $<TARGET_FILE:${TARGET_NAME}>
213     COMMAND llvm-profdata merge -sparse ${TARGET_NAME}.profraw -o ${TARGET_NAME}.profdata
214     DEPENDS ${TARGET_NAME})
215
216   add_custom_target(${TARGET_NAME}-ccov-show
217     COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions ${COV_SOURCES}
218     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
219
220   add_custom_target(${TARGET_NAME}-ccov-report
221     COMMAND llvm-cov report -show-functions $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata ${COV_SOURCES}
222     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
223
224   add_custom_target(${TARGET_NAME}-ccov
225     COMMAND llvm-cov show $<TARGET_FILE:${TARGET_NAME}> -instr-profile=${TARGET_NAME}.profdata -show-line-counts-or-regions -output-dir=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov -format="html" ${COV_SOURCES}
226     DEPENDS ${TARGET_NAME}-ccov-preprocessing)
227
228   add_custom_command(TARGET ${TARGET_NAME}-ccov POST_BUILD
229     COMMAND ;
230     COMMENT "Open ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TARGET_NAME}-llvm-cov/index.html in your browser to view the coverage report."
231 )
232 endif()