Skip to content

Commit

Permalink
Merge pull request iqiyi#570 from iqiyi/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
mscbg authored May 27, 2020
2 parents 8cf34e1 + 7196c80 commit 3e5fffb
Show file tree
Hide file tree
Showing 69 changed files with 1,671 additions and 3,805 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ $ make # or "make -j40" to speed up.
$ make install
```

> may need install dependencies, like `openssl`, `popt` and `numactl`, e.g., `yum install popt-devel` (CentOS).
> may need install dependencies, like `automake`, `libnl3`, `libnl-genl-3.0`, `openssl`, `popt` and `numactl`, e.g., `yum install popt-devel` (CentOS).
Output files are installed to `dpvs/bin`.

Expand Down
119 changes: 59 additions & 60 deletions include/conf/iftraf.h
Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
/*
* DPVS is a software load balancer (Virtual Server) based on DPDK.
*
* Copyright (C) 2017 iQIYI (www.iqiyi.com).
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
*/
#ifndef __DPVS_IFTRAF_CONF_H__
#define __DPVS_IFTRAF_CONF_H__
#include <stdint.h>
#include <linux/if_addr.h>
#include "inet.h"

enum {
/* set */
SOCKOPT_SET_IFTRAF_ADD = 6400,
SOCKOPT_SET_IFTRAF_DEL,

/* get */
SOCKOPT_GET_IFTRAF_SHOW,
};

struct dp_vs_iftraf_conf {
char ifname[IFNAMSIZ];
} __attribute__((__packed__));


struct iftraf_param {
uint8_t af;
uint8_t proto;
uint8_t cid;
uint16_t devid;
char ifname[IFNAMSIZ];
union inet_addr saddr;
union inet_addr daddr;
uint16_t sport;
uint16_t dport;

uint32_t total_recv;
uint32_t total_sent;

} __attribute__((__packed__));

struct iftraf_param_array {
int ntrafs;
struct iftraf_param iftraf[0];
};

#endif /* __DPVS_INETADDR_CONF_H__ */

/*
* DPVS is a software load balancer (Virtual Server) based on DPDK.
*
* Copyright (C) 2017 iQIYI (www.iqiyi.com).
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
*/
#ifndef __DPVS_IFTRAF_CONF_H__
#define __DPVS_IFTRAF_CONF_H__
#include <stdint.h>
#include <linux/if_addr.h>
#include "inet.h"

enum {
/* set */
SOCKOPT_SET_IFTRAF_ADD = 6400,
SOCKOPT_SET_IFTRAF_DEL,

/* get */
SOCKOPT_GET_IFTRAF_SHOW,
};

struct dp_vs_iftraf_conf {
char ifname[IFNAMSIZ];
} __attribute__((__packed__));


struct iftraf_param {
uint8_t af;
uint8_t proto;
uint8_t cid;
uint16_t devid;
char ifname[IFNAMSIZ];
union inet_addr saddr;
union inet_addr daddr;
uint16_t sport;
uint16_t dport;

uint32_t total_recv;
uint32_t total_sent;

} __attribute__((__packed__));

struct iftraf_param_array {
int ntrafs;
struct iftraf_param iftraf[0];
};

#endif /* __DPVS_INETADDR_CONF_H__ */
1 change: 1 addition & 0 deletions include/global_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern dpvs_lcore_role_t g_lcore_role[DPVS_MAX_LCORE];
* anything else -1
* */
extern int g_lcore_index[DPVS_MAX_LCORE];
extern int g_lcore_num;

int global_data_init(void);
int global_data_term(void);
Expand Down
73 changes: 36 additions & 37 deletions include/iftraf.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,36 @@
/*
* DPVS is a software load balancer (Virtual Server) based on DPDK.
*
* Copyright (C) 2017 iQIYI (www.iqiyi.com).
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
*/
#ifndef __IFTRAF_H__
#define __IFTRAF_H__

#include "conf/common.h"
#include "list.h"
#include "dpdk.h"
#include "timer.h"
#include "inet.h"
#include "ctrl.h"

int iftraf_sockopt_get(sockoptid_t opt, const void *conf, size_t size, void **out, size_t *outsize);

int iftraf_pkt_in(int af, struct rte_mbuf *mbuf, struct netif_port *dev);
int iftraf_pkt_out(int af, struct rte_mbuf *mbuf, struct netif_port *dev);

int iftraf_init(void);
int iftraf_term(void); /* cleanup */

#endif

/*
* DPVS is a software load balancer (Virtual Server) based on DPDK.
*
* Copyright (C) 2017 iQIYI (www.iqiyi.com).
* 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
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* 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.
*
*/
#ifndef __IFTRAF_H__
#define __IFTRAF_H__

#include "conf/common.h"
#include "list.h"
#include "dpdk.h"
#include "timer.h"
#include "inet.h"
#include "ctrl.h"

int iftraf_sockopt_get(sockoptid_t opt, const void *conf, size_t size, void **out, size_t *outsize);

int iftraf_pkt_in(int af, struct rte_mbuf *mbuf, struct netif_port *dev);
int iftraf_pkt_out(int af, struct rte_mbuf *mbuf, struct netif_port *dev);

int iftraf_init(void);
int iftraf_term(void); /* cleanup */

#endif
7 changes: 4 additions & 3 deletions include/ipvs/blklst.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

struct blklst_entry {
struct list_head list;
union inet_addr vaddr;
uint16_t vport;
int af;
uint8_t proto;
uint16_t vport;
union inet_addr vaddr;
union inet_addr blklst;
};

struct blklst_entry *dp_vs_blklst_lookup(uint8_t proto, const union inet_addr *vaddr,
struct blklst_entry *dp_vs_blklst_lookup(int af, uint8_t proto, const union inet_addr *vaddr,
uint16_t vport, const union inet_addr *blklst);
void dp_vs_blklst_flush(struct dp_vs_service *svc);

Expand Down
2 changes: 1 addition & 1 deletion include/ipvs/conn.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ dp_vs_conn_clear_redirect_hashed(struct dp_vs_conn *conn)
conn->flags &= ~DPVS_CONN_F_REDIRECT_HASHED;
}

inline uint32_t dp_vs_conn_hashkey(int af,
uint32_t dp_vs_conn_hashkey(int af,
const union inet_addr *saddr, uint16_t sport,
const union inet_addr *daddr, uint16_t dport,
uint32_t mask);
Expand Down
26 changes: 19 additions & 7 deletions include/ipvs/dest.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ dp_vs_dest_is_avail(struct dp_vs_dest *dest)
return (dest->flags & DPVS_DEST_F_AVAILABLE) ? true : false;
}

static inline void
dp_vs_dest_set_avail(struct dp_vs_dest *dest)
{
dest->flags |= DPVS_DEST_F_AVAILABLE;
}

static inline void
dp_vs_dest_clear_avail(struct dp_vs_dest *dest)
{
dest->flags &= ~DPVS_DEST_F_AVAILABLE;
}

static inline bool
dp_vs_dest_is_overload(struct dp_vs_dest *dest)
{
Expand All @@ -90,24 +102,24 @@ dp_vs_dest_is_valid(struct dp_vs_dest *dest)
&& dp_vs_dest_get_weight(dest) > 0) ? true : false;
}

int dp_vs_new_dest(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest,
int dp_vs_dest_new(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest,
struct dp_vs_dest **dest_p);

struct dp_vs_dest *dp_vs_lookup_dest(int af, struct dp_vs_service *svc,
struct dp_vs_dest *dp_vs_dest_lookup(int af, struct dp_vs_service *svc,
const union inet_addr *daddr, uint16_t dport);

int dp_vs_add_dest(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);
int dp_vs_dest_add(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);

int dp_vs_edit_dest(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);
int dp_vs_dest_edit(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);

void dp_vs_unlink_dest(struct dp_vs_service *svc,
void dp_vs_dest_unlink(struct dp_vs_service *svc,
struct dp_vs_dest *dest, int svcupd);

void dp_vs_dest_put(struct dp_vs_dest *dest);

int dp_vs_del_dest(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);
int dp_vs_dest_del(struct dp_vs_service *svc, struct dp_vs_dest_conf *udest);

int dp_vs_get_dest_entries(const struct dp_vs_service *svc,
int dp_vs_dest_get_entries(const struct dp_vs_service *svc,
struct dp_vs_get_dests *uptr);

int dp_vs_dest_init(void);
Expand Down
8 changes: 4 additions & 4 deletions include/ipvs/service.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ int dp_vs_match_parse(const char *srange, const char *drange,
const char *iifname, const char *oifname,
int af, struct dp_vs_match *match);

void dp_vs_bind_svc(struct dp_vs_dest *dest, struct dp_vs_service *svc);
void dp_vs_service_bind(struct dp_vs_dest *dest, struct dp_vs_service *svc);

void dp_vs_unbind_svc(struct dp_vs_dest *dest);
void dp_vs_service_unbind(struct dp_vs_dest *dest);

void dp_vs_svc_put(struct dp_vs_service *svc);
void dp_vs_service_put(struct dp_vs_service *svc);

struct dp_vs_service *dp_vs_lookup_vip(int af, uint16_t protocol,
struct dp_vs_service *dp_vs_vip_lookup(int af, uint16_t protocol,
const union inet_addr *vaddr,
lcoreid_t cid);

Expand Down
5 changes: 1 addition & 4 deletions include/ipvs/stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,13 @@ int dp_vs_stats_init(void);
int dp_vs_stats_term(void);

void dp_vs_stats_clear(struct dp_vs_stats *stats);

int dp_vs_stats_add(struct dp_vs_stats *dst, struct dp_vs_stats *src);
int dp_vs_stats_in(struct dp_vs_conn *conn, struct rte_mbuf *mbuf);
int dp_vs_stats_out(struct dp_vs_conn *conn, struct rte_mbuf *mbuf);
void dp_vs_stats_conn(struct dp_vs_conn *conn);

void dp_vs_estats_inc(enum dp_vs_estats_type field);
void dp_vs_estats_clear(void);
uint64_t dp_vs_estats_get(enum dp_vs_estats_type field);
int dp_vs_add_stats(struct dp_vs_stats* dst, struct dp_vs_stats* src);

int dp_vs_copy_stats(struct dp_vs_stats* dst, struct dp_vs_stats* src);

#endif /* __DPVS_STATS_H__ */
4 changes: 2 additions & 2 deletions include/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct dpvs_timer {
dpvs_tick_t delay;
};

inline dpvs_tick_t timeval_to_ticks(const struct timeval *tv);
inline void ticks_to_timeval(const dpvs_tick_t ticks, struct timeval *tv);
dpvs_tick_t timeval_to_ticks(const struct timeval *tv);
void ticks_to_timeval(const dpvs_tick_t ticks, struct timeval *tv);

int dpvs_timer_init(void);
int dpvs_timer_term(void);
Expand Down
2 changes: 1 addition & 1 deletion kmod/uoa/example/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
all: udp_serv uperf opp

CFLAGS = -g -O0
CFLAGS += -I ../../../include -I ../
CFLAGS += -I ../../../include/ -I ../../../include/conf -I ../

udp_serv: udp_serv.c
gcc $(CFLAGS) -o udp_serv udp_serv.c
Expand Down
Loading

0 comments on commit 3e5fffb

Please sign in to comment.