pfd_packet.c File Reference

Relating to processing packets in the fast path. More...

#include <string.h>
#include <signal.h>
#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in_systm.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#include <isc/eventlib.h>
#include <jnx/aux_types.h>
#include <jnx/vrf_util_pub.h>
#include <jnx/rt_shared_pub.h>
#include <jnx/jnx_types.h>
#include <jnx/mpsdk.h>
#include <jnx/atomic.h>
#include <sys/jnx/jbuf.h>
#include "pfd_packet.h"
#include "pfd_logging.h"
#include "pfd_config.h"
#include "pfd_conn.h"
#include "pfd_main.h"
#include "pfd_nat.h"

Go to the source code of this file.

Defines

#define VRFINDEX_ERROR   -1
 Error code when not able to get VRF index.
#define MAX_MSP_SEND_RETRIES   100
 Max msp_data_send retires before panic.
#define IP_NEEDED_BYTES   (sizeof(struct ip))
#define TCP_NEEDED_BYTES   (sizeof(struct ip) + sizeof(struct tcphdr))

Functions

static status_t pullup_bytes (struct jbuf **pkt_buf, uint16_t num_bytes)
static void * pfd_process_packet (msp_dataloop_args_t *params)
void init_packet_loops_config (void)
void destroy_packet_loops_config (void)
void init_packet_loops (void)
void stop_packet_loops (void)

Variables

static uint8_t next_id
 next thread ID to take
static pthread_mutex_t next_id_lock
 lock to control access
static int vrf_default
 default RI's VRF index
static int vrf_pfd_forwarding
 PFD RI's VRF index.
static atomic_uint_t loops_running
 # of data loops running
static volatile uint8_t do_shutdown
 do the data loops need to shutdown
thread_message_t update_messages [MAX_CPUS]


Detailed Description

Relating to processing packets in the fast path.

These functions and types will manage the packet processing in the fast path

Definition in file pfd_packet.c.


Define Documentation

#define IP_NEEDED_BYTES   (sizeof(struct ip))

Must have this many bytes of each packet in the jbuf to analyze it

Definition at line 58 of file pfd_packet.c.

Referenced by pfd_process_packet().

#define TCP_NEEDED_BYTES   (sizeof(struct ip) + sizeof(struct tcphdr))

Must have this many bytes of each packet in the jbuf to analyze it for nat

Definition at line 63 of file pfd_packet.c.

Referenced by pfd_process_packet().


Function Documentation

void destroy_packet_loops_config ( void   ) 

Destroy config for packet loop threads

Definition at line 379 of file pfd_packet.c.

References MAX_CPUS, next_id_lock, and update_messages.

Referenced by pfd_quit(), and pfd_shutdown().

void init_packet_loops ( void   ) 

Start packet loops

Definition at line 395 of file pfd_packet.c.

References do_shutdown, LOG, loops_running, pfd_process_packet(), pfd_shutdown(), RI_PFD_FORWARDING, vrf_default, vrf_pfd_forwarding, and VRFINDEX_ERROR.

Referenced by cpd_client_connection(), and ped_client_message().

void init_packet_loops_config ( void   ) 

Init config for packet loop threads

Definition at line 362 of file pfd_packet.c.

References MAX_CPUS, next_id, next_id_lock, and update_messages.

Referenced by pfd_init().

static void* pfd_process_packet ( msp_dataloop_args_t *  params  )  [static]

Entry point for packet processing threads (function passed to pthread_create)

Parameters:
[in] params dataloop parameters with user data, loop identifier, and loop number

Definition at line 129 of file pfd_packet.c.

References thread_message_s::addresses, address_bundle_s::cpd_addr, do_shutdown, IP_NEEDED_BYTES, is_auth_user(), LOCK_MUTEX, LOG, loops_running, MAX_MSP_SEND_RETRIES, nat_fragment(), nat_packet(), next_id, next_id_lock, address_bundle_s::pfd_addr, pullup_bytes(), reverse_nat_packet(), TCP_NEEDED_BYTES, UNLOCK_MUTEX, thread_message_s::update, update_messages, vrf_default, and vrf_pfd_forwarding.

Referenced by init_packet_loops().

static status_t pullup_bytes ( struct jbuf **  pkt_buf,
uint16_t  num_bytes 
) [static]

Ensure or pullup enough data into the first jbuf of the chain in order to analyze it better where the bytes are contiguous

Parameters:
[in] pkt_buf The packet in jbuf format (chain of jbufs)
[in] num_bytes The number of contiguous bytes of data required in the first jbuf
Returns:
Returns the result of the jbuf_pullup on the pkt_buf upon SUCCESS; otherwise pkt_buf remains unchanged and EFAIL is returned

Definition at line 105 of file pfd_packet.c.

Referenced by pfd_process_packet().

void stop_packet_loops ( void   ) 

Stop packet loops

Definition at line 455 of file pfd_packet.c.

References do_shutdown, and loops_running.

Referenced by pfd_quit(), and pfd_shutdown().


Variable Documentation

thread_message_t update_messages[MAX_CPUS]

update messages for threads' config. Defined in the packet module

Definition at line 84 of file pfd_packet.c.

Referenced by destroy_packet_loops_config(), init_packet_loops_config(), ped_client_message(), and pfd_process_packet().


2007-2009 Juniper Networks, Inc. All rights reserved. The information contained herein is confidential information of Juniper Networks, Inc., and may not be used, disclosed, distributed, modified, or copied without the prior written consent of Juniper Networks, Inc. in an express license. This information is subject to change by Juniper Networks, Inc. Juniper Networks, the Juniper Networks logo, and JUNOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners.
Generated on Sun May 30 20:27:07 2010 for SDK Your Net Corporation Policy Manager Example: Packet Filtering Daemon (pfd) 1.0 by Doxygen 1.5.1