-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cilium: Set privileged options for listener socket as well
Patch Envoy to support setting socket options from listener filters and use them to set privileged options for the listener. Minor cleanup in socket option implementation to move unused fields from SocketMarkOption class to SocketOption where they are used. Signed-off-by: Jarno Rajahalme <[email protected]>
- Loading branch information
1 parent
4840d77
commit f2ea823
Showing
5 changed files
with
128 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
From 0f7c83d1a8d634b3f5909016e2a1eafd50acc639 Mon Sep 17 00:00:00 2001 | ||
From: Jarno Rajahalme <[email protected]> | ||
Date: Mon, 14 Aug 2023 10:01:21 +0300 | ||
Subject: [PATCH] Revert "listener: keep ListenerFactoryContext small (#7528)" | ||
|
||
This reverts commit 170c89eb0b2afb7a39d44d0f8dfb77444ffc038f. | ||
|
||
diff --git a/envoy/server/factory_context.h b/envoy/server/factory_context.h | ||
index ed4b946b38..efc2e49ef8 100644 | ||
--- a/envoy/server/factory_context.h | ||
+++ b/envoy/server/factory_context.h | ||
@@ -309,6 +309,11 @@ public: | ||
*/ | ||
class ListenerFactoryContext : public virtual FactoryContext { | ||
public: | ||
+ /** | ||
+ * Store socket options to be set on the listen socket before listening. | ||
+ */ | ||
+ virtual void addListenSocketOptions(const Network::Socket::OptionsSharedPtr& options) PURE; | ||
+ | ||
/** | ||
* Give access to the listener configuration | ||
*/ | ||
diff --git a/source/extensions/listener_managers/listener_manager/listener_impl.cc b/source/extensions/listener_managers/listener_manager/listener_impl.cc | ||
index 94b29a189e..bb2cc17115 100644 | ||
--- a/source/extensions/listener_managers/listener_manager/listener_impl.cc | ||
+++ b/source/extensions/listener_managers/listener_manager/listener_impl.cc | ||
@@ -907,6 +907,9 @@ envoy::config::core::v3::TrafficDirection PerListenerFactoryContextImpl::directi | ||
return listener_factory_context_base_->direction(); | ||
}; | ||
TimeSource& PerListenerFactoryContextImpl::timeSource() { return api().timeSource(); } | ||
+void PerListenerFactoryContextImpl::addListenSocketOptions(const Network::Socket::OptionsSharedPtr& options) { | ||
+ listener_impl_.addListenSocketOptions(options); | ||
+} | ||
const Network::ListenerConfig& PerListenerFactoryContextImpl::listenerConfig() const { | ||
return *listener_config_; | ||
} | ||
diff --git a/source/extensions/listener_managers/listener_manager/listener_impl.h b/source/extensions/listener_managers/listener_manager/listener_impl.h | ||
index 4dfbd43b5a..9da9fa4d5a 100644 | ||
--- a/source/extensions/listener_managers/listener_manager/listener_impl.h | ||
+++ b/source/extensions/listener_managers/listener_manager/listener_impl.h | ||
@@ -241,6 +241,7 @@ public: | ||
bool isQuicListener() const override; | ||
|
||
// ListenerFactoryContext | ||
+ void addListenSocketOptions(const Network::Socket::OptionsSharedPtr& options) override; | ||
const Network::ListenerConfig& listenerConfig() const override; | ||
|
||
ListenerFactoryContextBaseImpl& parentFactoryContext() { return *listener_factory_context_base_; } | ||
@@ -383,6 +384,13 @@ public: | ||
return config().traffic_direction(); | ||
} | ||
|
||
+ void addListenSocketOptions(const Network::Socket::OptionsSharedPtr& append_options) { | ||
+ for (std::vector<Network::Address::InstanceConstSharedPtr>::size_type i = 0; | ||
+ i < addresses_.size(); i++) { | ||
+ addListenSocketOptions(listen_socket_options_list_[i], append_options); | ||
+ } | ||
+ } | ||
+ | ||
void ensureSocketOptions(Network::Socket::OptionsSharedPtr& options) { | ||
if (options == nullptr) { | ||
options = std::make_shared<std::vector<Network::Socket::OptionConstSharedPtr>>(); | ||
diff --git a/test/mocks/server/factory_context.h b/test/mocks/server/factory_context.h | ||
index e1327228eb..db110d263e 100644 | ||
--- a/test/mocks/server/factory_context.h | ||
+++ b/test/mocks/server/factory_context.h | ||
@@ -46,6 +46,7 @@ public: | ||
MOCK_METHOD(envoy::config::core::v3::TrafficDirection, direction, (), (const)); | ||
MOCK_METHOD(TimeSource&, timeSource, ()); | ||
|
||
+ MOCK_METHOD(void, addListenSocketOptions, (const Network::Socket::OptionsSharedPtr&)); | ||
MOCK_METHOD(const Network::ListenerConfig&, listenerConfig, (), (const)); | ||
|
||
Event::TestTimeSystem& timeSystem() { return time_system_; } | ||
diff --git a/test/mocks/server/listener_factory_context.h b/test/mocks/server/listener_factory_context.h | ||
index 5341b517d1..924b8cb0b1 100644 | ||
--- a/test/mocks/server/listener_factory_context.h | ||
+++ b/test/mocks/server/listener_factory_context.h | ||
@@ -20,6 +20,7 @@ public: | ||
MockListenerFactoryContext(); | ||
~MockListenerFactoryContext() override; | ||
|
||
+ MOCK_METHOD(void, addListenSocketOptions, (const Network::Socket::OptionsSharedPtr&)); | ||
const Network::ListenerConfig& listenerConfig() const override { return listener_config_; } | ||
MOCK_METHOD(const Network::ListenerConfig&, listenerConfig_, (), (const)); | ||
MOCK_METHOD(ServerFactoryContext&, getServerFactoryContext, (), (const)); | ||
-- | ||
2.41.0 | ||
|