/* * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: LicenseRef-NvidiaProprietary * * NVIDIA CORPORATION, its affiliates and licensors retain all intellectual * property and proprietary rights in and to this material, related * documentation and any modifications thereto. Any use, reproduction, * disclosure or distribution of this material and related documentation * without an express license agreement from NVIDIA CORPORATION or * its affiliates is strictly prohibited. */ #include #include #include #include struct usermeta_t { bit<32> entropy; }; control c( inout nv_headers_t headers, in nv_standard_metadata_t std_meta, inout usermeta_t user_meta, inout nv_empty_metadata_t pkt_out_meta ) { // Create a hash object with the selected algorithm NvHash(NvHashAlgorithm.CRC32) hash; action drop() { nv_drop(); } action transmit(nv_logical_port_t port) { nv_send_to_port(port); } table balancer { key = { headers.ipv4.dst_addr: lpm; } actions = { drop; transmit; } default_action = drop; size = 1024; } apply { if (headers.vxlan.isValid() && std_meta.is_inner_l4_ok != 0) { user_meta.entropy = hash.get_hash( 65536, { headers.inner_ipv4.src_addr, headers.inner_ipv4.dst_addr, headers.inner_ipv4.protocol, std_meta.inner_l4_src_port, std_meta.inner_l4_dst_port } ); nv_set_l4_src_port(headers, (bit<16>)user_meta.entropy); balancer.apply(); } } } NvDocaPipeline( nv_fixed_parser(), c() ) main;