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

Udps dev #11

Draft
wants to merge 34 commits into
base: stable/2110
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d4849de
Added the code structure and infra
rajithpr-eng Dec 15, 2022
76d3724
cli_first_cut
rranjan03 Dec 15, 2022
ad72f75
Merge pull request #4 from rranjan03/udps-cli-first-cut
rajithpr-eng Dec 15, 2022
73624ff
Added the API prototypes and structure definitions
rajithpr-eng Dec 15, 2022
53de55a
Added skeleton functions
rajithpr-eng Dec 15, 2022
6ac54f9
dummy commit for hackathon
bmital Dec 14, 2022
ad26291
dummy commit 2
bmital Dec 14, 2022
911bce1
cscope build file
bmital Dec 15, 2022
9d28d01
skeletal for nodes
bmital Dec 15, 2022
0a6fc6f
Merge pull request #3 from bmital/udps-dev
rajithpr-eng Dec 15, 2022
1ff5756
Added all set apis
rajithpr-eng Dec 15, 2022
20f76e8
node loop for 1 pkt processing
bmital Dec 15, 2022
02eba81
Merge pull request #5 from bmital/udps-dev
rajithpr-eng Dec 15, 2022
fd950a1
Added match api for the lookup
rajithpr-eng Dec 15, 2022
a96feca
Completed get apis
rajithpr-eng Dec 15, 2022
ae08e0e
set commands
rranjan03 Dec 15, 2022
2e359ed
Merge pull request #6 from rranjan03/udps-cli-set-policy-action
rajithpr-eng Dec 15, 2022
860cef6
rule action implemented in rx/tx nodes
bmital Dec 15, 2022
b502589
show_cli_changes
rranjan03 Dec 15, 2022
7e0ac46
Merge pull request #7 from bmital/udps-dev
rajithpr-eng Dec 15, 2022
15f67f8
bug fix in interface-tx name
bmital Dec 15, 2022
ffe8d0c
Merge pull request #9 from bmital/udps-dev
rajithpr-eng Dec 15, 2022
14efc4c
Merge pull request #8 from rranjan03/udps-show-cli
rajithpr-eng Dec 15, 2022
77d9561
Fixes found during integration
rajithpr-eng Dec 16, 2022
0a00917
Made get APIs for policy public
rajithpr-eng Jan 5, 2023
9c1e9ba
imporve policy rule and policy action cli
rranjan03 Jan 5, 2023
e110e5b
Merge branch 'udps-dev' of github.com:rajithpr-eng/vpp-fdio into impr…
rranjan03 Jan 5, 2023
13ca1d2
Added delete apis
rajithpr-eng Jan 5, 2023
37cc078
show multiple rule per policy
rranjan03 Jan 5, 2023
e27f11d
Merge pull request #10 from rranjan03/improve_show_cli
rajithpr-eng Jan 5, 2023
ae85e5b
show policy on interface and show policy by given name
rranjan03 Jan 5, 2023
6c45110
Merge pull request #12 from rranjan03/show_interface_policy
rajithpr-eng Jan 6, 2023
229d9f0
delete cli
rranjan03 Jan 6, 2023
0cc84cf
Merge pull request #13 from rranjan03/delete_cli
rajithpr-eng Jan 6, 2023
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
27 changes: 27 additions & 0 deletions src/bld_cscope.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

echo -e "\033[36m Building Cscope ...\033[0m"
uname=`uname -s`
if [ x$uname == xLinux ]
then
find -type f -and -regex '.*/.*\.\(c\|cpp\|cc\|h\|hpp\|p4\|s\|asm\|py\|proto\|spec\|go\)$' > cscope.files
find ../platform/ -type f -and -regex '.*/.*\.\(c\|cpp\|cc\|h\|hpp\|p4\|s\|asm\|py\|proto\|spec\|go\)$' >> cscope.files
elif [ x$uname == xDarwin ]
then
find . -name '*.c' 2> /dev/null > cscope.files
find . -name '*.cpp' 2> /dev/null >> cscope.files
find . -name '*.cc' 2> /dev/null >> cscope.files
find . -name '*.hpp' 2> /dev/null >> cscope.files
find . -name '*.p4' 2> /dev/null >> cscope.files
find . -name '*.s' 2> /dev/null >> cscope.files
find . -name '*.asm' 2> /dev/null >> cscope.files
find . -name '*.py' 2> /dev/null >> cscope.files
find . -name '*.proto' 2> /dev/null >> cscope.files
find . -name '*.spec' 2> /dev/null >> cscope.files
find . -name '*.go' 2> /dev/null >> cscope.files
fi

cscope -b -q


echo -e "\033[36m Done !! \033[0m"
19 changes: 19 additions & 0 deletions src/plugins/udps/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2018 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

add_vpp_plugin(udps
SOURCES
udps_node.c
udps_cli.c
udps_db.c
)
138 changes: 138 additions & 0 deletions src/plugins/udps/udps.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
#ifndef __UDPS_H__
#define __UDPS_H__

#define UDPS_NO_PORT (~0)
#define UDPS_NO_ACTION (NULL)
#define UDPS_INVALID_RULE (255)
#define UDPS_INVALID_POLICY_ID (~0)

enum udps_rewrite_oper_e {
UDPS_REWRITE_UNUSED = 0,
UDPS_REWRITE_INSERT,
UDPS_REWRITE_REPLACE,
UDPS_REWRITE_REMOVE
};

enum udps_match_oper_e {
UDPS_MATCH_UNUSED = 0,
UDPS_MATCH_PKT,
};

typedef struct udps_rewrite_s {
u8 oper;
u16 offset;
u8 *value;
u8 len;
} udps_rewrite_t;

typedef struct udps_rule_action_s {
u8 *name;
udps_rewrite_t *rewrite;
u32 out_port;
} udps_rule_action_t;

typedef struct udps_match_pkt_s {
u16 offset;
u8 *value;
} udps_match_pkt_t;

typedef struct udps_rule_entry_s {
u8 rule_id;
udps_match_pkt_t *match_pkt;
u32 act_id;
} udps_rule_entry_t;

typedef struct udps_policy_entry_s {
u8 *name;
udps_rule_entry_t *rules;
} udps_policy_entry_t;

typedef struct udps_main_s {
u32 *ing_policy_by_sw_if_index;
u32 *egr_policy_by_sw_if_index;
udps_policy_entry_t *policy_db;
udps_rule_action_t *action_db;
uword *action_by_name;
uword *policy_by_name;
} udps_main_t;

/* Add a rule action.
Creates action if not present.
If already present updates the existing one.
name, oper are mandatory.
oper determines which of offset, value, len are set.
*/
void udps_db_rule_action_add(u8 *name, u8 oper, u16 offset, u8 *value, u8 len, u32 out_port);

/* Delete a rule action.
Deletes action if not used by a policy.
If used, returns false.
*/
bool udps_db_rule_action_del(u8 *name);

/* Get a rule action.
If present, rule action is returned in ra.
Otherwise, returns false.
*/
bool udps_db_rule_action_get(u8 *name, udps_rule_action_t **ra);

/* Get a matching rule action for the packet.
If present, rule action is returned in ra.
Otherwise, returns false.
*/
bool udps_db_rule_match(u32 sw_if_index, u8 is_rx, u8 *bytes, u16 len, udps_rule_action_t **ra);

/* Add a rule entry.
Creates rule entry if not present.
If already present updates the existing one.
name, id, oper are mandatory.
oper determines if offset, value is valid.
If aname is not created yet, returns false.
*/
bool udps_db_rule_entry_add(u8 *name, u8 id, u8 oper, u16 offset, u8 *value, u8 *aname);

/* Get the rule entry count.
*/
u8 udps_db_rule_entry_cnt(u8 *name);

/* Get a rule entry.
If present, rule entry is returned in re.
Otherwise, returns false.
*/
bool udps_db_rule_entry_get(u8 *name, u8 id, udps_rule_entry_t **re);

/* Delete a policy.
Deletes policy if not used by an interface.
If used, returns false.
*/
bool udps_db_rule_policy_del(u8 *name);

/* Applies policy on interface in the given direction.
*/
void udps_db_policy_apply(u32 sw_if_index, u8 is_rx, u8 *name);

/* Removes policy on interface in the given direction.
*/
void udps_db_policy_remove(u32 sw_if_index, u8 is_rx);

/* Applies policy on interface in the given direction.
*/
void udps_node_policy_apply(u32 sw_if_index, u8 is_rx);

/* Removes policy on interface in the given direction.
*/
void udps_node_policy_remove(u32 sw_if_index, u8 is_rx);

/* Get policy by name.
If present, policy entry is returned in pe.
Otherwise, returns false.
*/
bool udps_db_rule_policy_get(u8 *name, udps_policy_entry_t **pe);

/* Get policy on interface in the given direction.
If present, policy entry is returned in pe.
Otherwise, returns false.
*/
bool udps_db_policy_get_by_sw_if_index(u32 sw_if_index, u8 is_rx, udps_policy_entry_t **pe);

#endif /* __UDPS_H__ */
Loading