Skip to content

Commit f54c420

Browse files
kristof-matteicathay4t
authored andcommitted
fix: none of these methods modify the socket, they merely modify the kernel's state
1 parent 51c01b6 commit f54c420

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/socket.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl Socket {
410410
Ok(res as usize)
411411
}
412412

413-
pub fn set_pktinfo(&mut self, value: bool) -> Result<()> {
413+
pub fn set_pktinfo(&self, value: bool) -> Result<()> {
414414
let value: libc::c_int = value.into();
415415
setsockopt(
416416
self.as_raw_fd(),
@@ -429,7 +429,7 @@ impl Socket {
429429
Ok(res == 1)
430430
}
431431

432-
pub fn add_membership(&mut self, group: u32) -> Result<()> {
432+
pub fn add_membership(&self, group: u32) -> Result<()> {
433433
setsockopt(
434434
self.as_raw_fd(),
435435
libc::SOL_NETLINK,
@@ -438,7 +438,7 @@ impl Socket {
438438
)
439439
}
440440

441-
pub fn drop_membership(&mut self, group: u32) -> Result<()> {
441+
pub fn drop_membership(&self, group: u32) -> Result<()> {
442442
setsockopt(
443443
self.as_raw_fd(),
444444
libc::SOL_NETLINK,
@@ -457,7 +457,7 @@ impl Socket {
457457
/// `NETLINK_BROADCAST_ERROR` (since Linux 2.6.30). When not set,
458458
/// `netlink_broadcast()` only reports `ESRCH` errors and silently
459459
/// ignore `NOBUFS` errors.
460-
pub fn set_broadcast_error(&mut self, value: bool) -> Result<()> {
460+
pub fn set_broadcast_error(&self, value: bool) -> Result<()> {
461461
let value: libc::c_int = value.into();
462462
setsockopt(
463463
self.as_raw_fd(),
@@ -478,7 +478,7 @@ impl Socket {
478478

479479
/// `NETLINK_NO_ENOBUFS` (since Linux 2.6.30). This flag can be used by
480480
/// unicast and broadcast listeners to avoid receiving `ENOBUFS` errors.
481-
pub fn set_no_enobufs(&mut self, value: bool) -> Result<()> {
481+
pub fn set_no_enobufs(&self, value: bool) -> Result<()> {
482482
let value: libc::c_int = value.into();
483483
setsockopt(
484484
self.as_raw_fd(),
@@ -502,7 +502,7 @@ impl Socket {
502502
/// have an nsid assigned into the network namespace where the socket
503503
/// has been opened. The nsid is sent to user space via an ancillary
504504
/// data.
505-
pub fn set_listen_all_namespaces(&mut self, value: bool) -> Result<()> {
505+
pub fn set_listen_all_namespaces(&self, value: bool) -> Result<()> {
506506
let value: libc::c_int = value.into();
507507
setsockopt(
508508
self.as_raw_fd(),
@@ -527,7 +527,7 @@ impl Socket {
527527
/// The netlink message header is still included, so the user can
528528
/// guess from the sequence number which message triggered the
529529
/// acknowledgment.
530-
pub fn set_cap_ack(&mut self, value: bool) -> Result<()> {
530+
pub fn set_cap_ack(&self, value: bool) -> Result<()> {
531531
let value: libc::c_int = value.into();
532532
setsockopt(
533533
self.as_raw_fd(),
@@ -549,7 +549,7 @@ impl Socket {
549549
/// `NETLINK_EXT_ACK`
550550
/// Extended ACK controls reporting of additional error/warning TLVs in
551551
/// NLMSG_ERROR and NLMSG_DONE messages.
552-
pub fn set_ext_ack(&mut self, value: bool) -> Result<()> {
552+
pub fn set_ext_ack(&self, value: bool) -> Result<()> {
553553
let value: libc::c_int = value.into();
554554
setsockopt(
555555
self.as_raw_fd(),
@@ -697,7 +697,7 @@ mod test {
697697

698698
#[test]
699699
fn options() {
700-
let mut sock = Socket::new(NETLINK_ROUTE).unwrap();
700+
let sock = Socket::new(NETLINK_ROUTE).unwrap();
701701

702702
sock.set_cap_ack(true).unwrap();
703703
assert!(sock.get_cap_ack().unwrap());

0 commit comments

Comments
 (0)