bool allowed(Envoy::Http::RequestHeaderMap& headers, Cilium::AccessLog::Entry& log_entry) const {
auto value = header.has_range_match() ? fmt::format("[{}-{})", header.range_match().start(),
ENVOY_LOG(trace, "Cilium L7 HttpNetworkPolicyRule(): HeaderData {}={}", header.name(), value);
L7NetworkPolicyRule(const NetworkPolicyMapImpl& parent, const cilium::L7NetworkPolicyRule& rule)
ENVOY_LOG(trace, "Cilium L7 PortNetworkPolicyRule(): Allowing SNI {} by rule {}", sni, name_);
bool allowed(uint32_t proxy_id, uint32_t remote_id, absl::string_view sni, bool& denied) const {
std::vector<HttpNetworkPolicyRule> http_rules_; // Allowed if empty, but remote is checked first.
bool allowed(uint32_t proxy_id, uint32_t remote_id, absl::string_view sni, bool& denied) const {
// wildcard-port rules, as either of them could contain rules that must be evaluated (i.e., deny
// rules for the specific ports are checked first, and within there singe-port ranges are placed in
// the front, while actual ranges are placed in the back. This results in the following precedence
bool PortPolicy::forFirstRange(std::function<bool(const PortNetworkPolicyRules&)> f) const {
bool PortPolicy::useProxylib(uint32_t proxy_id, uint32_t remote_id, std::string& l7_proto) const {
bool PortPolicy::allowed(uint32_t proxy_id, uint32_t remote_id, absl::string_view sni) const {
// Construction is single-threaded, but all other use is from multiple worker threads using const
// closed. This does not happen if new listener(s) with references to policy map are created in
// Destruction of the NetworkPolicyMapImpl must be made from the main thread to ensure integrity
// onConfigUpdate parses the new network policy resources, allocates a new policy map and atomically
const auto& config = dynamic_cast<const cilium::NetworkPolicy&>(resource.get().resource());
// entered their event loop, and thus relinquished all state, such as policy lookup results that
// variable that would take a thread local slot for no other purpose than to avoid this type cast.
dynamic_cast<ThreadLocal::Instance&>(context_.threadLocal()).runOnAllWorkerThreads([]() {}, cb);
// Returning a default deny policy makes the caller report a "policy deny" rather than "internal
// server error" if no policy is found. This mirrors what bpf datapath does if no policy entry is
// found in the bpf policy map. The default deny for ingress with default allow for egress is needed