Skip to content

Commit

Permalink
Merge pull request bpfman#849 from Billy99/billy99-panic-unwrap
Browse files Browse the repository at this point in the history
bpfman: Fix panic if XDP prog already loaded
  • Loading branch information
mergify[bot] authored Nov 29, 2023
2 parents 217087d + 472a9c8 commit d556f26
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 642 deletions.
12 changes: 10 additions & 2 deletions bpfman/src/multiprog/xdp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ impl XdpDispatcher {
.unwrap();
} else {
let flags = self.mode.as_flags();
let link = dispatcher.attach(&iface, flags).unwrap();
let link = dispatcher.attach(&iface, flags).map_err(|e| {
BpfmanError::Error(format!(
"dispatcher attach failed on interface {iface}: {e}"
))
})?;
let owned_link = dispatcher.take_link(link)?;
let path = format!("{RTDIR_FS_XDP}/dispatcher_{if_index}_link");
let _ = TryInto::<FdLink>::try_into(owned_link)
.unwrap() // TODO: Don't unwrap, although due to minimum kernel version this shouldn't ever panic
.map_err(|e| {
BpfmanError::Error(format!(
"FdLink conversion failed on interface {iface}: {e}"
))
})?
.pin(path)
.map_err(BpfmanError::UnableToPinLink)?;
}
Expand Down
Loading

0 comments on commit d556f26

Please sign in to comment.