wireguard: fix crash by not sending arp via wg interface
[vpp.git] / src / plugins / wireguard / wireguard_peer.h
index a08fff7..a14f269 100644 (file)
@@ -33,12 +33,26 @@ typedef struct ip4_udp_header_t_
   udp_header_t udp;
 } __clib_packed ip4_udp_header_t;
 
+typedef struct ip4_udp_wg_header_t_
+{
+  ip4_header_t ip4;
+  udp_header_t udp;
+  message_data_t wg;
+} __clib_packed ip4_udp_wg_header_t;
+
 typedef struct ip6_udp_header_t_
 {
   ip6_header_t ip6;
   udp_header_t udp;
 } __clib_packed ip6_udp_header_t;
 
+typedef struct ip6_udp_wg_header_t_
+{
+  ip6_header_t ip6;
+  udp_header_t udp;
+  message_data_t wg;
+} __clib_packed ip6_udp_wg_header_t;
+
 u8 *format_ip4_udp_header (u8 * s, va_list * va);
 u8 *format_ip6_udp_header (u8 *s, va_list *va);
 
@@ -152,6 +166,8 @@ wg_peer_get (index_t peeri)
 static inline index_t
 wg_peer_get_by_adj_index (index_t ai)
 {
+  if (ai >= vec_len (wg_peer_by_adj_index))
+    return INDEX_INVALID;
   return (wg_peer_by_adj_index[ai]);
 }