MCPcopy
hub / github.com/osrg/gobgp / add_flowspec_rule

Function add_flowspec_rule

tools/grpc/python/flowspec_mitigation.py:192–237  ·  view source on GitHub ↗

Add a FlowSpec rule to GoBGP and return its UUID.

(stub, params)

Source from the content-addressed store, hash-verified

190
191
192def add_flowspec_rule(stub, params):
193 """Add a FlowSpec rule to GoBGP and return its UUID."""
194 rules = _build_flowspec_rules(params)
195 if not rules:
196 raise ValueError("no match criteria specified")
197
198 nlri = nlri_pb2.NLRI(
199 flow_spec=nlri_pb2.FlowSpecNLRI(rules=rules)
200 )
201
202 attributes = [
203 attribute_pb2.Attribute(
204 origin=attribute_pb2.OriginAttribute(origin=0)
205 ),
206 ]
207
208 action_community = _build_action(params)
209 if action_community is not None:
210 attributes.append(
211 attribute_pb2.Attribute(
212 extended_communities=(
213 attribute_pb2.ExtendedCommunitiesAttribute(
214 communities=[action_community]
215 )
216 )
217 )
218 )
219
220 family = _detect_family(params)
221
222 response = stub.AddPath(
223 gobgp_pb2.AddPathRequest(
224 table_type=gobgp_pb2.TABLE_TYPE_GLOBAL,
225 path=gobgp_pb2.Path(
226 nlri=nlri,
227 pattrs=attributes,
228 family=family,
229 ),
230 ),
231 timeout=_TIMEOUT_SECONDS,
232 )
233
234 uuid = response.uuid.hex()
235 with _lock:
236 _active_rules[uuid] = params
237 return uuid
238
239
240def delete_flowspec_rule(stub, uuid):

Callers 1

do_POSTMethod · 0.85

Calls 4

_build_flowspec_rulesFunction · 0.85
_build_actionFunction · 0.85
_detect_familyFunction · 0.85
AddPathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…