Couple of potential issues which I see: 1.) if this buffer is generated by vpp, it should be flagged as such (b->flags |= VNET_BUFFER_LOCALLY_ORIGINATED;)
2.) I don't see it passed to another node - you need to create a frame and associate the buffer with it, then pass the frame to the next node, which would be either ip4-arp or ip4-rewrite for ipv4 case depending on whether the arp resolution has taken place or not... take a look at functions bfd_udp_init() - where the next nodes are resolved bfd_transport_udp4() - where the next node is decided and frame created You can take a look at show error and show trace to see what happens to the packet.. HTH, Klement Quoting Alessio Silvestro (2017-06-16 17:20:30) > Dear Klement, > > thanks for the hint. I had a look at the code bfd_main.c and in particular > at the function bfd_send_periodic(). > > I wrote the function send_udp_packet() -- see below -- in order to send > out UDP packets. > > The function is executed (I can see from the VPP terminal) and no > exception is raised, however I do not see any packet out. > > 1 -- is the function correct or I am missing something? > > 2 -- if it is not correct, how I can see where the problem is? > > Thanks, > > Alessio > > static void send_udp_packet(vlib_main_t * vm, vlib_node_runtime_t * rt){ > u32 bi; > vlib_buffer_alloc (vm, &bi, 1) > vlib_buffer_t *b = vlib_get_buffer (vm, bi); > ASSERT (b->current_data == 0); > memset (vnet_buffer (b), 0, sizeof (*vnet_buffer (b))); > VLIB_BUFFER_TRACE_TRAJECTORY_INIT (b); > add_udp4_transport (vm,b); > } > > int add_udp4_transport (vlib_main_t * vm, vlib_buffer_t * b) > { > vnet_buffer (b)->ip.adj_index[VLIB_RX] = ~0; > vnet_buffer (b)->ip.adj_index[VLIB_TX]= ~0; > vnet_buffer (b)->sw_if_index[VLIB_RX] = 0; > vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0; > u8 *data; > udp_header_t *udp; > ip4_header_t *ip; > data = vlib_buffer_get_current (b); > udp = (udp_header_t *) (data - sizeof (udp_header_t)); > ip = (ip4_header_t *) ((u8 *) udp - sizeof (ip4_header_t)); > // Build packet header > u32 src_address = 167772161; //[1]10.0.0.1 u32 version > u32 dst_address = 167772162; // 10.0.0.2 u32 version > ip->src_address.as_u32 = src_address; > ip->dst_address.as_u32 = dst_address; > ip->ip_version_and_header_length = 0x45; > ip->ttl = 254; > ip->protocol = IP_PROTOCOL_UDP; //0x45 == IP_PROTOCOL_UDP > ip->length = clib_host_to_net_u16 (b->current_length + sizeof (*udp)); > ip->checksum = ip4_header_checksum (ip); > udp->src_port = DNS_SERVER_PORT; > udp->dst_port = DNS_DST_PORT; > udp->length = clib_host_to_net_u16 (b->current_length); > udp->checksum = 0; > b->current_length = sizeof (*ip) + sizeof (*udp); > return 1; > } > > On Wed, Jun 14, 2017 at 6:56 PM, Klement Sekera -X (ksekera - PANTHEON > TECHNOLOGIES at Cisco) <[2]ksek...@cisco.com> wrote: > > Hi Alessio, > > you can take a look at BFD code which > > a.) creates and sends its own UDP packets - bfd_main.c - > bfd_send_periodic() creates, encapsulates (UDP) and sends a packet out > b.) loops back packets received - bfd_udp.c - bfd_udp_echo_input() > > I'm not sure what's your use case, whether you are trying to reuse > existing buffer, but one of these should fit it. > > Regards, > Klement > > Quoting Alessio Silvestro (2017-06-14 17:22:14) > > Dear all, > > I implemented a new VPP node that receives UDP traffic using the > following > > function: > > > > udp_register_dst_port (vm, PORT, my_node.index , 1 /* is_ip4 */); > > > > I am able to parse the packet and I would like to be able to send > back an > > UDP packet. > > > > Looking at the source code, the only function that seems fit my > scope is > > the following (in ~/vpp/src/vnet/udp/udp.h) > > > > ip_udp_encap_one (vlib_main_t * vm, vlib_buffer_t * b0, u8 * ec0, > word > > ec_len, > > > > u8 is_ip4) > > > > Is that correct or there is another function for this purpose? > > > > Thanks in advance for any help. > > > > Best regards, > > > > Alessio > > References > > Visible links > 1. http://10.0.0.1/ > 2. mailto:ksek...@cisco.com _______________________________________________ vpp-dev mailing list vpp-dev@lists.fd.io https://lists.fd.io/mailman/listinfo/vpp-dev