Skip to content

Commit 6d654cc

Browse files
authored
Merge pull request eclipse-score#52 from qorix-group/prabakaran_fix_ttl_range
net: Fix ttl range
2 parents adc83eb + 52a41e6 commit 6d654cc

File tree

10 files changed

+15
-36
lines changed

10 files changed

+15
-36
lines changed

src/kyron/src/mio/net/tcp_listener.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ impl<T: IoSelector> TcpListenerBridge<T> {
5959
self.inner.as_inner().ttl()
6060
}
6161

62-
pub fn set_ttl(&self, ttl: u32) -> IoResult<()> {
63-
self.inner.as_inner().set_ttl(ttl)
62+
pub fn set_ttl(&self, ttl: u8) -> IoResult<()> {
63+
self.inner.as_inner().set_ttl(ttl as u32)
6464
}
6565
}
6666

src/kyron/src/mio/net/tcp_stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl<T: IoSelector> TcpStreamBridge<T> {
7373
self.inner.as_inner().ttl()
7474
}
7575

76-
pub fn set_ttl(&self, ttl: u32) -> IoResult<()> {
77-
self.inner.as_inner().set_ttl(ttl)
76+
pub fn set_ttl(&self, ttl: u8) -> IoResult<()> {
77+
self.inner.as_inner().set_ttl(ttl as u32)
7878
}
7979
}
8080

src/kyron/src/mio/net/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ impl<T: IoSelector> UdpSocketBridge<T> {
7575
self.inner.as_inner().ttl()
7676
}
7777

78-
pub fn set_ttl(&self, ttl: u32) -> IoResult<()> {
79-
self.inner.as_inner().set_ttl(ttl)
78+
pub fn set_ttl(&self, ttl: u8) -> IoResult<()> {
79+
self.inner.as_inner().set_ttl(ttl as u32)
8080
}
8181

8282
pub fn local_addr(&self) -> IoResult<SocketAddr> {

src/kyron/src/net/tcp_listener.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl TcpListener {
7474

7575
/// Sets the value for the IP_TTL option on this socket.
7676
/// This value sets the time-to-live field that is used in every packet sent from this socket.
77-
pub fn set_ttl(&self, ttl: u32) -> NetResult<()> {
77+
pub fn set_ttl(&self, ttl: u8) -> NetResult<()> {
7878
self.listener.set_ttl(ttl)
7979
}
8080
}

src/kyron/src/net/tcp_stream.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl TcpStream {
6969

7070
/// Sets the value for the IP_TTL option on this socket.
7171
/// This value sets the time-to-live field that is used in every packet sent from this socket.
72-
pub fn set_ttl(&self, ttl: u32) -> NetResult<()> {
72+
pub fn set_ttl(&self, ttl: u8) -> NetResult<()> {
7373
self.stream.set_ttl(ttl)
7474
}
7575

src/kyron/src/net/udp_socket.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ impl UdpSocket {
124124

125125
/// Sets the value for the IP_TTL option on this socket.
126126
/// This value sets the time-to-live field that is used in every packet sent from this socket.
127-
pub fn set_ttl(&self, ttl: u32) -> NetResult<()> {
127+
pub fn set_ttl(&self, ttl: u8) -> NetResult<()> {
128128
self.socket.set_ttl(ttl)
129129
}
130130
}

tests/test_cases/tests/runtime/net/tcp/test_tcp_listener.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,9 @@ def test_ttl_ok(self, address: Address, logs_info_level: LogContainer, ttl: int
168168

169169

170170
class TestTTL_Invalid(TestTTL):
171-
@pytest.fixture(scope="class", params=[0, 256, 257, 2**16, 2**32 - 1])
171+
@pytest.fixture(scope="class", params=[0])
172172
def ttl(self, request: pytest.FixtureRequest) -> int | None:
173-
value = request.param
174-
if value == 2**32 - 1:
175-
pytest.xfail(
176-
reason="Max u32 value sets TTL to default - https://github.com/qorix-group/inc_orchestrator_internal/issues/327"
177-
)
178-
179-
return value
173+
return request.param
180174

181175
def capture_stderr(self) -> bool:
182176
return True

tests/test_cases/tests/runtime/net/tcp/test_tcp_stream.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,9 @@ def test_ttl_ok(
239239

240240

241241
class TestTTL_Invalid(TestTTL):
242-
@pytest.fixture(scope="class", params=[0, 256, 257, 2**16, 2**32 - 1])
242+
@pytest.fixture(scope="class", params=[0])
243243
def ttl(self, request: pytest.FixtureRequest) -> int | None:
244-
value = request.param
245-
if value == 2**32 - 1:
246-
pytest.xfail(
247-
reason="Max u32 value sets TTL to default - https://github.com/qorix-group/inc_orchestrator_internal/issues/327"
248-
)
249-
250-
return value
244+
return request.param
251245

252246
def capture_stderr(self) -> bool:
253247
return True

tests/test_cases/tests/runtime/net/udp/test_udp_server.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,16 +149,7 @@ def scenario_name(self) -> str:
149149

150150
@pytest.fixture(
151151
scope="class",
152-
params=[
153-
0,
154-
256,
155-
pytest.param(
156-
2**32 - 1,
157-
marks=pytest.mark.xfail(
158-
reason="Max u32 value sets TTL to default - https://github.com/qorix-group/inc_orchestrator_internal/issues/327",
159-
),
160-
),
161-
],
152+
params=[0],
162153
)
163154
def ttl(self, request: pytest.FixtureRequest) -> int | None:
164155
return request.param

tests/test_scenarios/rust/src/internals/net_helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ where
2323
pub struct ConnectionParameters {
2424
#[serde(flatten, deserialize_with = "deserialize_socket_addr")]
2525
address: SocketAddr,
26-
ttl: Option<u32>,
26+
ttl: Option<u8>,
2727
}
2828

2929
impl ConnectionParameters {

0 commit comments

Comments
 (0)