Skip to content

Commit

Permalink
fix network rbac connection close without reason (#26879)
Browse files Browse the repository at this point in the history
Signed-off-by: wangkai19 <wangkai19@corp.netease.com>
  • Loading branch information
StarryVae authored Apr 24, 2023
1 parent 606dedc commit 28f222f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion source/extensions/filters/network/rbac/rbac_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ Network::FilterStatus RoleBasedAccessControlFilter::onData(Buffer::Instance&, bo
} else if (engine_result_ == Deny) {
callbacks_->connection().streamInfo().setConnectionTerminationDetails(
Filters::Common::RBAC::responseDetail(log_policy_id));
callbacks_->connection().close(Network::ConnectionCloseType::NoFlush);
callbacks_->connection().close(Network::ConnectionCloseType::NoFlush, "rbac_deny_close");
return Network::FilterStatus::StopIteration;
}

Expand Down
4 changes: 2 additions & 2 deletions test/extensions/filters/network/rbac/filter_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ TEST_F(RoleBasedAccessControlNetworkFilterTest, Denied) {
setDestinationPort(456);
setMetadata();

EXPECT_CALL(callbacks_.connection_, close(Network::ConnectionCloseType::NoFlush)).Times(2);
EXPECT_CALL(callbacks_.connection_, close(Network::ConnectionCloseType::NoFlush, _)).Times(2);

// Call onData() twice, should only increase stats once.
EXPECT_EQ(Network::FilterStatus::StopIteration, filter_->onData(data_, false));
Expand Down Expand Up @@ -424,7 +424,7 @@ TEST_F(RoleBasedAccessControlNetworkFilterTest, MatcherDenied) {
setDestinationPort(456);
setMetadata();

EXPECT_CALL(callbacks_.connection_, close(Network::ConnectionCloseType::NoFlush)).Times(2);
EXPECT_CALL(callbacks_.connection_, close(Network::ConnectionCloseType::NoFlush, _)).Times(2);

// Call onData() twice, should only increase stats once.
EXPECT_EQ(Network::FilterStatus::StopIteration, filter_->onData(data_, false));
Expand Down

0 comments on commit 28f222f

Please sign in to comment.