net/embms-kernel : EMBMS Tunneling Module

This module is used to tunnel multicast
packets received on an interface to WLAN
clients which have registered for these
packet streams. Mainly used to tunnel
EMBMS packets received on TMGI streams.

Change-Id: I996077342261ec2cb688e98319c6881d2dd7cce2
Acked-by: Sneha <smaganah@qti.qualcomm.com>
Signed-off-by: Mohammed Javid <mjavid@codeaurora.org>
tirimbino
Ravinder Konka 9 years ago committed by Gerrit - the friendly Code Review server
parent 0e75cda318
commit c71e69eee8
  1. 8
      net/core/dev.c
  2. 22
      net/embms_kernel/Makefile
  3. 1051
      net/embms_kernel/embms_kernel.c
  4. 233
      net/embms_kernel/embms_kernel.h

@ -4327,6 +4327,9 @@ static inline int nf_ingress(struct sk_buff *skb, struct packet_type **pt_prev,
return 0;
}
int (*embms_tm_multicast_recv)(struct sk_buff *skb) __rcu __read_mostly;
EXPORT_SYMBOL(embms_tm_multicast_recv);
static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
{
struct packet_type *ptype, *pt_prev;
@ -4335,6 +4338,7 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc)
bool deliver_exact = false;
int ret = NET_RX_DROP;
__be16 type;
int (*embms_recv)(struct sk_buff *skb);
net_timestamp_check(!netdev_tstamp_prequeue, skb);
@ -4391,6 +4395,10 @@ skip_taps:
}
#endif
skb_reset_tc(skb);
embms_recv = rcu_dereference(embms_tm_multicast_recv);
if (embms_recv)
embms_recv(skb);
skip_classify:
if (pfmemalloc && !skb_pfmemalloc_protocol(skb))
goto drop;

@ -0,0 +1,22 @@
#
# Makefile for Embms Kernel module.
#
KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
obj-m += embms_kernel.o
ccflags-y += -D__CHECK_ENDIAN__
CDEFINES += -D__CHECK_ENDIAN__
KBUILD_CPPFLAGS += $(CDEFINES)
all:
$(MAKE) -C $(KERNEL_SRC) M=$(shell pwd) modules
modules_install:
$(MAKE) INSTALL_MOD_STRIP=1 -C $(KERNEL_SRC) M=$(shell pwd) modules_install
clean:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) clean

File diff suppressed because it is too large Load Diff

@ -0,0 +1,233 @@
/******************************************************************
* Copyright (c) 2013-2015,2017, 2018 The Linux Foundation. All rights reserved.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
*---------------------------------------------------------------
* DESCRIPTION
* Header file for eMBMs Tunneling Module in kernel.
*******************************************************************
*/
#ifndef EMBMS_H
#define EMBMS_H
#include <linux/ioctl.h>
#include <stdbool.h>
#include <linux/if_addr.h>
#include <linux/list.h>
#include <linux/ip.h>
#include <linux/miscdevice.h>
#include <linux/spinlock.h>
#include <linux/cdev.h>
#define EMBMS_MAX_IFACE_NAME 20
/* Defining IP and UDP header related macros*/
#define UDP_CHECKSUM 0
#define IP_VERSION 4
#define IP_IHL 5
#define IP_TOS 0
#define IP_ID 1
#define IP_FRAG_OFFSET htons(0x4000)
#define IP_TTL 64
#define BRIDGE_IFACE "bridge0"
#define BUF_LEN 1024
#define TUNNELING_ON 1
#define TUNNELING_OFF 0
// definitions required for IOCTL
static unsigned int dev_num = 1;
/* Embms device used for communication*/
struct cdev embms_device;
static struct class *embms_class;
static dev_t device;
#define EMBMS_IOC_MAGIC 0x64
#define embms_debug pr_debug
#define embms_error pr_debug
/* The name of the device file*/
#define EMBMS_DEVICE_NAME "embms_tm_device"
extern int (*embms_tm_multicast_recv)(struct sk_buff *skb);
/**
* enum embms_action_type - Describes action to perform
* @ADD_CLIENT_ENTRY: add client entry to TMGI
* @DELETE_CLIENT_ENTRY: deelte client entry from TMGI
* @TMGI_DEACTIVATE: Delete TMGI entry
* @CLIENT_ACTIVATE_ALL_TMGI: Add client to all TMGI
* @CLIENT_DEACTIVATE_ALL_TMGI: Delete client from all TMGI
* @SESSION_DEACTIVATE: Stop session
* @SOCK_INFO: Socket information like V4 addr, port etc
*
* This enum defines the types of action which are
* supported by this module.
*/
enum {
ADD_CLIENT_ENTRY = 0,
DELETE_CLIENT_ENTRY,
TMGI_DEACTIVATE,
CLIENT_ACTIVATE_ALL_TMGI,
CLIENT_DEACTIVATE_ALL_TMGI,
SESSION_DEACTIVATE,
SOCK_INFO
} embms_action_type;
/**
* struct tmgi_to_clnt_info_update - information for addition/deletion
* @multicast_addr: TMGI multicast IP to receive data
* @multicast_port: TMGI multicast port to receive date
* @client_addr: Client IPV4 address for sending data
* @client_port: Client port for sending data
* @data_port: port used to send data to client
* @action_type: Action to be performed
* @iface_name: iface to listen to for data
*
* This structure contains information as to what action
* needs to be performed on TMGI-client table. It is
* sent as a parameter during an IOCTL call
*/
struct tmgi_to_clnt_info_update {
u32 multicast_addr;
u16 multicast_port;
u32 client_addr;
u16 client_port;
u16 data_port;
u32 action_type;
char iface_name[EMBMS_MAX_IFACE_NAME];
};
/**
* struct clnt_info - contains client information
* @addr: Client IPV4 address for sending packets
* @port: Client port for sending packets
* @dmac: Client DMAC address
* @client_list_ptr : list ptr used to maintain client list
*
* This structure maintains complete client information
* to be used when sending packets to client
*/
struct clnt_info {
u32 addr;
u16 port;
u8 dmac[ETH_ALEN];
struct list_head client_list_ptr;
};
/**
* struct tmgi_to_clnt_info - contains TMGI information
* @tmgi_multicast_addr: TMGI IPV4 address to listen for packets
* @tmgi_port: Client port to listen for packets
* @no_of_clients: No of clients for a TMGI
* @client_list_head : list head for client list
* @tmgi_list_ptr : list ptr to maintain tmgi list
*
* This structure maintains complete client information
* to be used when sending data to client
*/
struct tmgi_to_clnt_info {
u32 tmgi_multicast_addr;
u16 tmgi_port;
u16 no_of_clients;
struct list_head client_list_head;
struct list_head tmgi_list_ptr;
};
/**
* struct embms_info_internal - stores module specific params
* @device_under_use: Used to prevent concurent access to the same device
* @embms_data_port: Source Data port used for tunnelled packets
* @embms_iface: Iface to receive embms traffic
* @embms_tunneling_status : Current EMBMS Status
* @no_of_tmgi_sessions : Number of current active TMGI sessions
* @lock : Lock for concurrency scenarios
* @ip_ident : IP identification number to be used for sent packets
*
* This tructure holds module specific information which is
* used throughout the module to maintain consistency
*/
struct embms_info_internal {
atomic_t device_under_use;
int embms_data_port;
char embms_iface[EMBMS_MAX_IFACE_NAME];
int embms_tunneling_status;
int no_of_tmgi_sessions;
/*lock to prevent concurrent access*/
spinlock_t lock;
atomic_t ip_ident;
};
/* This ioctl is used to add a new client entry to tunneling module.
* Entry params are populated in the struct used for ioctl
*/
#define ADD_EMBMS_TUNNEL _IOW(EMBMS_IOC_MAGIC, 0, \
struct tmgi_to_clnt_info_update)
/* This ioctl is used to delete a client entry for a particular
* TMGI from tunneling module.
* Entry params are populated in the struct used for ioctl
*/
#define DEL_EMBMS_TUNNEL _IOW(EMBMS_IOC_MAGIC, 1, \
struct tmgi_to_clnt_info_update)
/* This ioctl is used to delete a TMGI entry completely
* from tunneling module.
* Entry params are populated in the struct used for ioctl
*/
#define TMGI_DEACTIVATE _IOW(EMBMS_IOC_MAGIC, 2, \
struct tmgi_to_clnt_info_update)
/* This ioctl is used to delete client entry completely
* from tunneling module.
* Entry params are populated in the struct used for ioctl
*/
#define CLIENT_DEACTIVATE _IOW(EMBMS_IOC_MAGIC, 3, \
struct tmgi_to_clnt_info_update)
/* Gets the ON/OFF status of Tunneling module*/
#define GET_EMBMS_TUNNELING_STATUS _IO(EMBMS_IOC_MAGIC, 4)
/* Used to start tunneling. Argument is the port
* number to be used to send
* data to clients
*/
#define START_EMBMS_TUNNEL _IOW(EMBMS_IOC_MAGIC, 5, \
struct tmgi_to_clnt_info_update)
/* Used to stop tunnleing*/
#define STOP_EMBMS_TUNNEL _IO(EMBMS_IOC_MAGIC, 6)
/* Return values indicating error status*/
#define SUCCESS 0 /* Successful operation*/
#define FAILURE -1 /* Unsuccessful operation*/
/* Error Condition Values*/
#define ENOMEM -2 /* Out of memory*/
#define EBADPARAM -3 /* Incorrect parameters passed*/
#define ENOEFFECT -4 /* No Effect*/
#endif
Loading…
Cancel
Save