Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ftctl: forwarding table display utility #101

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ clean:
make -C src/glb-healthcheck clean
make -C src/glb-director clean
make -C src/glb-director/cli clean
make -C src/glb-director/ftctl clean
1 change: 1 addition & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ Vagrant.configure("2") do |config|
dpdk-devbind --bind=igb_uio eth1
dpdk-devbind --status

apt install /vagrant/tmp/build/glb-director-cli*.deb
apt install /vagrant/tmp/build/glb-director_*.deb
apt install /vagrant/tmp/build/glb-healthcheck_*.deb

Expand Down
66 changes: 4 additions & 62 deletions src/glb-director/cli/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,72 +38,14 @@

#include "log.h"

#define GLB_BACKEND_HEALTH_DOWN 0
#define GLB_BACKEND_HEALTH_UP 1
#include "glb_consts.h"
#include "glb_config_types.h"

#define GLB_BACKEND_STATE_FILLING 0
#define GLB_BACKEND_STATE_ACTIVE 1
#define GLB_BACKEND_STATE_DRAINING_INACTIVE 2

// http://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml
#define GLB_FAMILY_RESERVED 0
#define GLB_FAMILY_IPV4 1
#define GLB_FAMILY_IPV6 2

#define GLB_IPPROTO_UDP 17
#define GLB_IPPROTO_TCP 6

int siphash(uint8_t *out, const uint8_t *in, uint64_t inlen, const uint8_t *k);

#pragma pack(1)

typedef struct {
uint32_t file_fmt_ver;
uint32_t num_tables;
uint32_t table_entries;
uint32_t max_num_backends;
uint32_t max_num_binds;
} bin_file_header;

typedef struct {
uint32_t inet_family;

union {
char v6[16];
struct {
uint32_t v4;
char reserved[12];
};
} ip;

uint16_t state;
uint16_t health;
} backend_entry;

typedef struct {
uint32_t inet_family;

union {
char v6[16];
struct {
uint32_t v4;
char _[12];
};
} ip;

uint16_t ip_bits;

uint16_t port_start;
uint16_t port_end;
uint8_t ipproto;
uint8_t reserved;
} bind_entry;

typedef struct {
uint32_t primary_idx;
uint32_t secondary_idx;
} table_entry;

typedef struct {
uint32_t index;
uint64_t hash;
Expand Down Expand Up @@ -404,9 +346,9 @@ int main(int argc, char *argv[])
free(bind_ip);

if (!strcmp(bind_proto, "tcp")) {
entry.ipproto = GLB_IPPROTO_TCP;
entry.ipproto = IPPROTO_TCP;
} else if (!strcmp(bind_proto, "udp")) {
entry.ipproto = GLB_IPPROTO_UDP;
entry.ipproto = IPPROTO_UDP;
} else {
glb_log_error_and_exit("Bad protocol!");
}
Expand Down
50 changes: 50 additions & 0 deletions src/glb-director/ftctl/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# BSD 3-Clause License
#
# Copyright (c) 2019 Roblox Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
## Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
## Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
## Neither the name of the copyright holder nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
all: glb-ftctl

FTCTL_SRCS = main.c
WERROR_FLAGS += -Werror

CFLAGS += -O3 -g -Wall $(WERROR_FLAGS)

APP = glb-ftctl

glb-ftctl: $(FTCTL_SRCS)
gcc \
$(FTCTL_SRCS) \
$(CFLAGS) \
-I`pwd`/..\
-I`pwd`/../../glb-redirect/ \
-o glb-ftctl


clean:
rm -Rf glb-ftctl
54 changes: 54 additions & 0 deletions src/glb-director/ftctl/glb-ftctl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* BSD 3-Clause License
*
* Copyright (c) 2019 Roblox Corporation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
52 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __GLB_FTCTL_H__
#define __GLB_FTCTL_H__

#define FTCTL_TABLE_ENTRIES_ALL ((uint32_t)~0)
#define FTCTL_CHECK_IF_ENTRIES_ALL (x) ((x) == FTCTL_TABLE_ENTRIES_ALL)
#define FTCTL_CHECK_IF_ENTRIES_ALL_OR_THIS(x, y) \
(((x) == FTCTL_TABLE_ENTRIES_ALL) || ((x) == y))


typedef struct ftctl_config_ {
boolean detailed; /* d: print everything other than table-entries */
uint32_t table_num; /* n: print only the entries for table_num */

boolean verbose; /* v: print everything */
} ftctl_config_t;

#endif
/*
* Local variables:
* c-indent-level: 4
* c-basic-offset: 4
* End:
*/
Loading