Commit ea28029a authored by Franck Messaoudi's avatar Franck Messaoudi

Update: formatting some files

parent e64d6c81
...@@ -59,12 +59,12 @@ class SessionManager { ...@@ -59,12 +59,12 @@ class SessionManager {
virtual ~SessionManager(); virtual ~SessionManager();
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
// /** // /**
// * @brief Create a Session object in BPF map. // * @brief Create a Session object in BPF map.
// * // *
// * @param pSession The session object to be created. // * @param pSession The session object to be created.
// */ // */
// void createSession(std::shared_ptr<SessionBpf> pSession); // void createSession(std::shared_ptr<SessionBpf> pSession);
/*---------------------------------------------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------------------------------------------*/
/** /**
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include <linux/if_ether.h> #include <linux/if_ether.h>
//#define UDP_CSUM_OFFSET (sizeof(struct ethhdr) + offsetof(struct udphdr, //#define UDP_CSUM_OFFSET (sizeof(struct ethhdr) + offsetof(struct udphdr,
//check)) // check))
// static u32 udp_handle( // static u32 udp_handle(
// struct xdp_md* ctx, struct udphdr* udph, u32 src_ip, u32 dest_ip); // struct xdp_md* ctx, struct udphdr* udph, u32 src_ip, u32 dest_ip);
......
...@@ -422,7 +422,7 @@ int xdp_handle_downlink(struct xdp_md* ctx) { ...@@ -422,7 +422,7 @@ int xdp_handle_downlink(struct xdp_md* ctx) {
return XDP_DROP; return XDP_DROP;
} }
// struct iphdr* iph = (struct iphdr*) ((void*) ethh + sizeof(*ethh)); // struct iphdr* iph = (struct iphdr*) ((void*) ethh + sizeof(*ethh));
struct iphdr* iph = (void*) (ethh + 1); struct iphdr* iph = (void*) (ethh + 1);
if ((void*) (iph + 1) > data_end) { if ((void*) (iph + 1) > data_end) {
...@@ -430,7 +430,7 @@ int xdp_handle_downlink(struct xdp_md* ctx) { ...@@ -430,7 +430,7 @@ int xdp_handle_downlink(struct xdp_md* ctx) {
return XDP_DROP; return XDP_DROP;
} }
bpf_debug("xxxxxxxxxxxx ip_dest: 0x%x", iph->daddr); bpf_debug("xxxxxxxxxxxx ip_dest: 0x%x", iph->daddr);
u32 ip_dest = bpf_htonl(iph->daddr); u32 ip_dest = bpf_htonl(iph->daddr);
struct session_id* session = struct session_id* session =
bpf_map_lookup_elem(&m_session_mapping, &ip_dest); bpf_map_lookup_elem(&m_session_mapping, &ip_dest);
...@@ -472,9 +472,9 @@ int xdp_handle_shaping(struct xdp_md* ctx) { ...@@ -472,9 +472,9 @@ int xdp_handle_shaping(struct xdp_md* ctx) {
return XDP_DROP; return XDP_DROP;
} }
//struct iphdr* iph = (struct iphdr*) ((void*) ethh + sizeof(*ethh)); // struct iphdr* iph = (struct iphdr*) ((void*) ethh + sizeof(*ethh));
struct iphdr* iph = (void*) (ethh + 1); struct iphdr* iph = (void*) (ethh + 1);
if ((void*) (iph + 1) > data_end) { if ((void*) (iph + 1) > data_end) {
bpf_debug("Error: Invalid IPv4 Packet"); bpf_debug("Error: Invalid IPv4 Packet");
return XDP_DROP; return XDP_DROP;
......
...@@ -35,13 +35,12 @@ ...@@ -35,13 +35,12 @@
#define TARGET_INTF 644 #define TARGET_INTF 644
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
static __always_inline u32 egress_sdf_filter( static __always_inline u32 egress_sdf_filter(struct __sk_buff* skb) {
struct __sk_buff* skb) { void* data = (void*) (long) skb->data;
void *data = (void *)(long)skb->data;
void* data_end = (void*) (long) skb->data_end; void* data_end = (void*) (long) skb->data_end;
struct ethhdr* ethh = data; struct ethhdr* ethh = data;
if ((void*) (ethh + 1) > data_end) { if ((void*) (ethh + 1) > data_end) {
bpf_debug("Error: Invalid Ethernet header"); bpf_debug("Error: Invalid Ethernet header");
return TC_ACT_SHOT; return TC_ACT_SHOT;
...@@ -81,13 +80,13 @@ static __always_inline u32 egress_sdf_filter( ...@@ -81,13 +80,13 @@ static __always_inline u32 egress_sdf_filter(
struct filter_key* key = {0}; struct filter_key* key = {0};
u8 protocol = iph_inner->protocol; u8 protocol = iph_inner->protocol;
//bpf_debug("Create Key for SDF Filter Map"); // bpf_debug("Create Key for SDF Filter Map");
key->src_ip = iph_inner->saddr; key->src_ip = iph_inner->saddr;
key->dst_ip = iph_inner->daddr; key->dst_ip = iph_inner->daddr;
key->protocol = protocol; key->protocol = protocol;
switch (protocol) { switch (protocol) {
case IPPROTO_UDP: { case IPPROTO_UDP: {
// Extract UDP header // Extract UDP header
...@@ -141,11 +140,10 @@ static __always_inline u32 egress_sdf_filter( ...@@ -141,11 +140,10 @@ static __always_inline u32 egress_sdf_filter(
} }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
static __always_inline u32 static __always_inline u32 ipv4_sdf_filter(struct __sk_buff* skb) {
ipv4_sdf_filter(struct __sk_buff* skb) { void* data = (void*) (long) skb->data;
void *data = (void *)(long)skb->data; void* data_end = (void*) (long) skb->data_end;
void *data_end = (void *)(long)skb->data_end;
struct ethhdr* ethh = data; struct ethhdr* ethh = data;
if ((void*) (ethh + 1) > data_end) { if ((void*) (ethh + 1) > data_end) {
...@@ -160,7 +158,7 @@ ipv4_sdf_filter(struct __sk_buff* skb) { ...@@ -160,7 +158,7 @@ ipv4_sdf_filter(struct __sk_buff* skb) {
return TC_ACT_SHOT; return TC_ACT_SHOT;
} }
u8 protocol = iph->protocol; u8 protocol = iph->protocol;
switch (protocol) { switch (protocol) {
case IPPROTO_UDP: { case IPPROTO_UDP: {
...@@ -182,15 +180,14 @@ ipv4_sdf_filter(struct __sk_buff* skb) { ...@@ -182,15 +180,14 @@ ipv4_sdf_filter(struct __sk_buff* skb) {
} }
} }
//--------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------
SEC("tc/egress") SEC("tc/egress")
int tc_filter_traffic(struct __sk_buff* skb) { int tc_filter_traffic(struct __sk_buff* skb) {
bpf_debug("==========< tc/egress: Filter Traffic >==========\n"); bpf_debug("==========< tc/egress: Filter Traffic >==========\n");
void *data = (void *)(long)skb->data; void* data = (void*) (long) skb->data;
void *data_end = (void *)(long)skb->data_end; void* data_end = (void*) (long) skb->data_end;
struct ethhdr* ethh = data; struct ethhdr* ethh = data;
...@@ -243,12 +240,12 @@ int tc_redirect_traffic(struct __sk_buff* skb) { ...@@ -243,12 +240,12 @@ int tc_redirect_traffic(struct __sk_buff* skb) {
int key = DOWNLINK, *ifindex; int key = DOWNLINK, *ifindex;
ifindex = bpf_map_lookup_elem(&m_egress_ifindex, &key); ifindex = bpf_map_lookup_elem(&m_egress_ifindex, &key);
if (ifindex) { if (ifindex) {
bpf_debug("TC_REDIRECT: Redirecting packet to N3 tc layer"); bpf_debug("TC_REDIRECT: Redirecting packet to N3 tc layer");
return bpf_redirect(*ifindex, 0); return bpf_redirect(*ifindex, 0);
} }
bpf_debug("TC Packets not redirected! Drop them"); bpf_debug("TC Packets not redirected! Drop them");
return TC_ACT_SHOT; return TC_ACT_SHOT;
} }
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
// uint64_t qfi; // uint64_t qfi;
// }; // };
struct s_fiveQosFlow { struct s_fiveQosFlow {
uint8_t gate; uint8_t gate;
uint64_t mbr; uint64_t mbr;
...@@ -35,6 +34,4 @@ struct s_fiveQosFlow { ...@@ -35,6 +34,4 @@ struct s_fiveQosFlow {
uint8_t qfi; uint8_t qfi;
}; };
#endif //__QOS_FLOW_H__ #endif //__QOS_FLOW_H__
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment