Skip to content

listener filter: hiding envoy internal from ListenerFilterCallbacks interface#22732

Merged
KBaichoo merged 8 commits intoenvoyproxy:mainfrom
soulxu:cleanup_listener_filter_callbacks
Aug 22, 2022
Merged

listener filter: hiding envoy internal from ListenerFilterCallbacks interface#22732
KBaichoo merged 8 commits intoenvoyproxy:mainfrom
soulxu:cleanup_listener_filter_callbacks

Conversation

@soulxu
Copy link
Copy Markdown
Member

@soulxu soulxu commented Aug 17, 2022

Signed-off-by: He Jie Xu hejie.xu@intel.com

Commit Message: listener filter: hiding envoy internal from ListenerFilterCallbacks interface
Additional Description:
Since #20728 remove the need for listener filter to register their own event, the dispatch() and continueFilterChain(bool) interfaces are needn't by any listener filter anymore, and we can hide those envoy internal from the listener filter now.

Risk Level: low
Testing: unittest
Docs Changes: n/a
Release Notes: n/a
Platform Specific Features: n/a

@soulxu soulxu force-pushed the cleanup_listener_filter_callbacks branch from bb9d6e6 to ec413bb Compare August 17, 2022 05:08
…nterface

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu soulxu force-pushed the cleanup_listener_filter_callbacks branch from 4f0c793 to 669384e Compare August 17, 2022 10:05
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Copy link
Copy Markdown
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two high level questions:

Moving continueFilterChain from interface to the concrete class, but how can the listener filters communicate the continue filter chain?

Would this remove the ability to have failure in the onAccept calls?

@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Aug 18, 2022

Two high level questions:

Moving continueFilterChain from interface to the concrete class, but how can the listener filters communicate the continue filter chain?

In the old day, the listener filter use continueFilterChain to trigger the processes (move to next filter or reject the connection) of envoy core code, since the listener filter registered its own callback with the file event. That is what #20728 removed.

Today, after having #20728, the listener filter only uses the FilterStatus to communicate with listener. The file event is registered by envoy core code now, and that callback will trigger the processes based on the listener filter returned FilterStatus.

Network::FilterStatus status = (*iter_)->onData(filter_buffer);

Would this remove the ability to have failure in the onAccept calls?

The listener filter just needs to close the sockets and returns Network::FilterStatus::StopIteration, then the envoy core code knows that the listener filter rejected the connection:

continueFilterChain(false);

Thanks for the review!

Copy link
Copy Markdown
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation and the change. We should just put this new understanding back into the code.

Network::ConnectionSocket& socket() override { return *socket_.get(); }
Event::Dispatcher& dispatcher() override;
void continueFilterChain(bool success) override;
void continueFilterChain(bool success);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this elsewhere since it's no longer part of the interface commented above and have it documented?

It seems like it's now split into either internal usage or external continueFilterChain(true) call that really just starts the filter chain. We could increase encapsulation splitting this out into startFilterChain() and continueFilterChain with the latter being private and startFilterChain just deferring to it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise comments in https://github.com/envoyproxy/envoy/pull/22732/files/e8563f3153394c2ffe8653ca9c9beef7e70dacc0#diff-6708370e112a5097f06e16009c3730b34f5ab0ee4f1e736f8816848409435888R122

and

virtual FilterStatus onAccept(ListenerFilterCallbacks& cb) PURE;

should be updated since the convention is changing e.g the filter doesn't call continue

Copy link
Copy Markdown
Member Author

@soulxu soulxu Aug 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move this elsewhere since it's no longer part of the interface commented above and have it documented?

The ActiveTcpSocket is a struct, its all members are public now, I guess that is for convenient for ActiveTcpListener access. And ActiveTcpListener is only place ActiveTcpSocket, and probably we think ActiveTcpSocket is kind of internal struct for ActiveTcpListener(since its only alive short time, it will be deleted when the connection passed all the listener filters or the connection rejected by listener filter)

It seems like it's now split into either internal usage or external continueFilterChain(true) call that really just starts the filter chain. We could increase encapsulation splitting this out into startFilterChain() and continueFilterChain with the latter being private and startFilterChain just deferring to it.

Yea, that is good idea! The ActiveTcpListener is the place to call startFileChain(), and that make the code clear. Just as above said the whole ActiveTcpSocket are public, not sure I should make continueFilterChain as private. But let me know if this is still something you think should be changed.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise comments in https://github.com/envoyproxy/envoy/pull/22732/files/e8563f3153394c2ffe8653ca9c9beef7e70dacc0#diff-6708370e112a5097f06e16009c3730b34f5ab0ee4f1e736f8816848409435888R122

and

virtual FilterStatus onAccept(ListenerFilterCallbacks& cb) PURE;

should be updated since the convention is changing e.g the filter doesn't call continue

got it, will update the comments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks great! It makes a lot of sense that a lot of the class was open as you said, but it seems like it has grown in responsibility e.g. internally buffering listener data.

Having some methods private (continueFilterChain, createListenerFilterBuffer) would make the interface more compact / easier to grok.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, let me try to improve that.

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu soulxu force-pushed the cleanup_listener_filter_callbacks branch from 61f9cd7 to 8679577 Compare August 19, 2022 03:15
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Aug 19, 2022

Sorry for having to do a force push due to I mess up with the DCO since my daily dev machine is down and the temp machine has the wrong git config.

Copy link
Copy Markdown
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks great!

/**
* Called when data read from the connection. If the filter chain doesn't get
* enough data, the filter chain can be stopped, then waiting for more data.
* Called when data read from the connection. If the filter doesn't get
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/data read/data is read

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thanks!

Network::ConnectionSocket& socket() override { return *socket_.get(); }
Event::Dispatcher& dispatcher() override;
void continueFilterChain(bool success) override;
void continueFilterChain(bool success);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks this looks great! It makes a lot of sense that a lot of the class was open as you said, but it seems like it has grown in responsibility e.g. internally buffering listener data.

Having some methods private (continueFilterChain, createListenerFilterBuffer) would make the interface more compact / easier to grok.

soulxu added 2 commits August 22, 2022 19:17
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu soulxu force-pushed the cleanup_listener_filter_callbacks branch from 763057e to ac12792 Compare August 22, 2022 11:20
soulxu added 2 commits August 22, 2022 20:35
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Signed-off-by: He Jie Xu <hejie.xu@intel.com>
@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Aug 22, 2022

/wait

that is something failed real

@KBaichoo
Copy link
Copy Markdown
Contributor

Seems like issue might be resolved by #22792

@soulxu
Copy link
Copy Markdown
Member Author

soulxu commented Aug 22, 2022

Seems like issue might be resolved by #22792

thanks!, let me wait for that merged

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Copy link
Copy Markdown
Contributor

@KBaichoo KBaichoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thanks!

@KBaichoo KBaichoo merged commit 350c7f9 into envoyproxy:main Aug 22, 2022
soulxu added a commit to soulxu/envoy that referenced this pull request Oct 13, 2022
…backs interface (envoyproxy#22732)"

This reverts commit 350c7f9.

Signed-off-by: He Jie Xu <hejie.xu@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants