File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 5151const Commands BPF::cmds = {
5252 {" add" , " BPFArg" , MODULE_CMD_FUNC (&BPF::CommandAdd),
5353 Command::THREAD_UNSAFE},
54+ {" delete" , " BPFArg" , MODULE_CMD_FUNC (&BPF::CommandDelete),
55+ Command::THREAD_UNSAFE},
5456 {" clear" , " EmptyArg" , MODULE_CMD_FUNC (&BPF::CommandClear),
5557 Command::THREAD_UNSAFE},
5658 {" get_initial_arg" , " EmptyArg" , MODULE_CMD_FUNC (&BPF::GetInitialArg),
@@ -125,6 +127,24 @@ CommandResponse BPF::CommandAdd(const bess::pb::BPFArg &arg) {
125127 return CommandSuccess ();
126128}
127129
130+ CommandResponse BPF::CommandDelete (const bess::pb::BPFArg &arg) {
131+ for (const auto &f : arg.filters ()) {
132+ if (f.gate () < 0 || f.gate () >= MAX_GATES) {
133+ return CommandFailure (EINVAL, " Invalid gate" );
134+ }
135+
136+ for (auto i = filters_.begin (); i != filters_.end (); ++i) {
137+ if (f.priority () == i->priority && f.gate () == i->gate &&
138+ f.filter () == i->exp ) {
139+ filters_.erase (i);
140+ break ;
141+ }
142+ }
143+ }
144+
145+ return CommandSuccess ();
146+ }
147+
128148CommandResponse BPF::CommandClear (const bess::pb::EmptyArg &) {
129149 DeInit ();
130150 return CommandSuccess ();
Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ class BPF final : public Module {
5454
5555 CommandResponse GetInitialArg (const bess::pb::EmptyArg &);
5656 CommandResponse CommandAdd (const bess::pb::BPFArg &arg);
57+ CommandResponse CommandDelete (const bess::pb::BPFArg &arg);
5758 CommandResponse CommandClear (const bess::pb::EmptyArg &arg);
5859
5960 private:
You can’t perform that action at this time.
0 commit comments