Bug 210380 - [patch] fix net/nload interface name fetching
Summary: [patch] fix net/nload interface name fetching
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Emanuel Haupt
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2016-06-19 00:27 UTC by Allan Jude
Modified: 2016-06-19 15:24 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (ehaupt)


Attachments
patch for net/nload (330 bytes, patch)
2016-06-19 00:27 UTC, Allan Jude
no flags Details | Diff
updated patch for net/nload (1.39 KB, patch)
2016-06-19 15:24 UTC, Allan Jude
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Allan Jude freebsd_committer freebsd_triage 2016-06-19 00:27:39 UTC
Created attachment 171560 [details]
patch for net/nload

net/nload gets the network interface device names via struct sockaddr_dl

struct sockaddr_dl {
        u_char  sdl_len;        /* Total length of sockaddr */
        u_char  sdl_family;     /* AF_LINK */
        u_short sdl_index;      /* if != 0, system given index for interface */
        u_char  sdl_type;       /* interface type */
        u_char  sdl_nlen;       /* interface name length, no trailing 0 reqd. */
        u_char  sdl_alen;       /* link level address length */
        u_char  sdl_slen;       /* link layer selector length */
        char    sdl_data[46];   /* minimum work area, can be larger;
                                   contains both if name and ll address */
};


The name is stored in sdl_data, but is no longer null terminated. The first sdl_nlen bytes are the device name, the sdl_alen bytes after that are the link level address (MAC address), etc.

This small patch makes nload read only the first sdl_alen bytes as the device name, instead of reading binary data as a string until it finds a null byte.

This happens to often work if the first byte of the mac address is 0.

before:
Device alc0~P+49▒d (1/11):
Device em0h^EÊ^W·o (2/11):

after:
Device alc0 (1/11):
Device em0 (2/11):
Comment 1 commit-hook freebsd_committer freebsd_triage 2016-06-19 09:44:35 UTC
A commit references this bug:

Author: ehaupt
Date: Sun Jun 19 09:44:21 UTC 2016
New revision: 417107
URL: https://svnweb.freebsd.org/changeset/ports/417107

Log:
  Fix interface name fetching.

  PR:		210380
  Submitted by:	allanjude
  Obtained from:	OpenBSD ports

Changes:
  head/net/nload/Makefile
  head/net/nload/files/
  head/net/nload/files/patch-src_devreader-bsd.cpp
Comment 2 Emanuel Haupt freebsd_committer freebsd_triage 2016-06-19 09:44:49 UTC
Committed, thanks!
Comment 3 Allan Jude freebsd_committer freebsd_triage 2016-06-19 15:24:04 UTC
Created attachment 171576 [details]
updated patch for net/nload

svn add missing files in patch