Skip to content
Open
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifest
Original file line number Diff line number Diff line change
Expand Up @@ -10933,6 +10933,7 @@ f usr/sbin/nscd 0555 root bin
f usr/sbin/nvmeadm 0555 root bin
f usr/sbin/nwamadm 0555 root bin
f usr/sbin/nwamcfg 0555 root bin
f usr/sbin/ovroute 0555 root bin
f usr/sbin/pbind 0555 root sys
f usr/sbin/pcitool 0555 root bin
f usr/sbin/ping 4555 root bin
Expand Down Expand Up @@ -12585,6 +12586,7 @@ f usr/share/man/man1m/nlsadmin.1m 0444 root bin
f usr/share/man/man1m/nscd.1m 0444 root bin
f usr/share/man/man1m/nvmeadm.1m 0444 root bin
f usr/share/man/man1m/nwamd.1m 0444 root bin
f usr/share/man/man1m/ovroute.1m 0444 root bin
f usr/share/man/man1m/passmgmt.1m 0444 root bin
f usr/share/man/man1m/pbind.1m 0444 root bin
f usr/share/man/man1m/pcitool.1m 0444 root bin
Expand Down
1 change: 1 addition & 0 deletions usr/src/cmd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ COMMON_SUBDIRS= \
oamuser \
oawk \
od \
ovroute \
pack \
pagesize \
passmgmt \
Expand Down
1 change: 1 addition & 0 deletions usr/src/cmd/mdb/common/modules/genunix/Makefile.files
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ GENUNIX_SRCS = \
nvpair.c \
pci.c \
pg.c \
qqcache.c \
rctl.c \
refhash.c \
refstr.c \
Expand Down
7 changes: 7 additions & 0 deletions usr/src/cmd/mdb/common/modules/genunix/genunix.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
#include "nvpair.h"
#include "pci.h"
#include "pg.h"
#include "qqcache.h"
#include "rctl.h"
#include "refhash.h"
#include "sobj.h"
Expand Down Expand Up @@ -4788,6 +4789,12 @@ static const mdb_walker_t walkers[] = {
{ "pcie_bus", "walk all pcie_bus_t's", pcie_bus_walk_init,
pcie_bus_walk_step, NULL },

/* from qqcache.c */
{ QQCACHE_WALK_NAME, QQCACHE_WALK_DESC,
qqcache_walk_init_cache, qqcache_walk_step, qqcache_walk_fini },
{ QQCACHE_HASH_WALK_NAME, QQCACHE_HASH_WALK_DESC,
qqcache_walk_init_hash, qqcache_walk_step, qqcache_walk_fini },

/* from rctl.c */
{ "rctl_dict_list", "walk all rctl_dict_entry_t's from rctl_lists",
rctl_dict_walk_init, rctl_dict_walk_step, NULL },
Expand Down
117 changes: 117 additions & 0 deletions usr/src/cmd/mdb/common/modules/genunix/qqcache.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright 2018, Joyent, Inc.
Comment thread
jasonbking marked this conversation as resolved.
Outdated
*/

#include <mdb/mdb_modapi.h>
#include <mdb/mdb_ctf.h>

#include <sys/qqcache.h>
#include <sys/qqcache_impl.h>

#include "qqcache.h"

typedef struct qqcache_walk_data {
size_t qwd_link_off;
} qqcache_walk_data_t;

typedef struct mdb_qqcache {
size_t qqc_link_off;
size_t qqc_nbuckets;
} mdb_qqcache_t;

static int
qqcache_walk_init(mdb_walk_state_t *wsp, boolean_t use_hash)
{
qqcache_walk_data_t *qwd;
uintptr_t base;
size_t i, n, qqc_list_sz;
int cache_off, bucket_off, list_off;
mdb_qqcache_t qc;

/* mdb_ctf_offsetof_by_name will print any errors */
cache_off = mdb_ctf_offsetof_by_name("qqcache_t", "qqc_lists");
if (cache_off == -1)
return (WALK_ERR);

bucket_off = mdb_ctf_offsetof_by_name("qqcache_t", "qqc_buckets");
if (bucket_off == -1)
return (WALK_ERR);

list_off = mdb_ctf_offsetof_by_name("qqcache_list_t", "qqcl_list");
if (list_off == -1)
return (WALK_ERR);

/* mdb_ctf_sizeof_by_name will print any errors */
qqc_list_sz = mdb_ctf_sizeof_by_name("qqcache_list_t");
if (qqc_list_sz == -1)
return (WALK_ERR);

if (mdb_ctf_vread(&qc, "qqcache_t", "mdb_qqcache_t", wsp->walk_addr,
0) == -1) {
mdb_warn("failed to read qqcache_t at %#lx", wsp->walk_addr);
return (WALK_ERR);
}

qwd = wsp->walk_data = mdb_zalloc(sizeof (*qwd), UM_SLEEP);
qwd->qwd_link_off = qc.qqc_link_off;

if (use_hash) {
base = wsp->walk_addr + bucket_off;
n = qc.qqc_nbuckets;
} else {
base = wsp->walk_addr + cache_off;
n = QQCACHE_NUM_LISTS;
}

for (i = 0; i < n; i++) {
wsp->walk_addr = base + i * qqc_list_sz + list_off;

if (mdb_layered_walk("list", wsp) == -1) {
mdb_warn("can't walk qqcache_t");
mdb_free(qwd, sizeof (*qwd));
return (WALK_ERR);
}
}

return (WALK_NEXT);
}

int
qqcache_walk_init_cache(mdb_walk_state_t *wsp)
{
return (qqcache_walk_init(wsp, B_FALSE));
}

int
qqcache_walk_init_hash(mdb_walk_state_t *wsp)
{
return (qqcache_walk_init(wsp, B_TRUE));
}

int
qqcache_walk_step(mdb_walk_state_t *wsp)
{
qqcache_walk_data_t *qwd = wsp->walk_data;
uintptr_t addr = wsp->walk_addr - qwd->qwd_link_off;

return (wsp->walk_callback(addr, wsp->walk_layer, wsp->walk_cbdata));
}

void
qqcache_walk_fini(mdb_walk_state_t *wsp)
{
qqcache_walk_data_t *qwd = wsp->walk_data;

mdb_free(qwd, sizeof (*qwd));
}
40 changes: 40 additions & 0 deletions usr/src/cmd/mdb/common/modules/genunix/qqcache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* This file and its contents are supplied under the terms of the
* Common Development and Distribution License ("CDDL"), version 1.0.
* You may only use this file in accordance with the terms of version
* 1.0 of the CDDL.
*
* A full copy of the text of the CDDL should have accompanied this
* source. A copy of the CDDL is also available via the Internet at
* http://www.illumos.org/license/CDDL.
*/

/*
* Copyright 2018, Joyent Inc.
*/

#ifndef _MDB_QQCACHE_H
#define _MDB_QQCACHE_H

#ifdef __cplusplus
extern "C" {
#endif

#define QQCACHE_WALK_NAME "qqcache"
#define QQCACHE_WALK_DESC "walk a qqcache (2Q cache)"

#define QQCACHE_HASH_WALK_NAME "qqhash"
#define QQCACHE_HASH_WALK_DESC "walk a qqcache (2Q cache) via the hash buckets"

struct mdb_walk_state;

extern int qqcache_walk_init_cache(struct mdb_walk_state *);
extern int qqcache_walk_init_hash(struct mdb_walk_state *);
extern int qqcache_walk_step(struct mdb_walk_state *);
extern void qqcache_walk_fini(struct mdb_walk_state *);

#ifdef __cplusplus
}
#endif

#endif /* _MDB_QQCACHE_H */
52 changes: 52 additions & 0 deletions usr/src/cmd/ovroute/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#

#
# Copyright 2020 Joyent, Inc.
#

PROG= ovroute
OBJS= ovroute.o
SRCS= $(OBJS:%.o=../%.c)

include ../Makefile.cmd
include ../Makefile.ctf

CSTD = $(CSTD_GNU99)
CLEANFILES += $(OBJS)
CPPFLAGS += -D_REENTRANT
CFLAGS += $(CCVERBOSE)
LDLIBS += -lumem -lofmt -ldladm -lsocket
$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG

.KEEP_STATE:

all: $(PROG)

$(PROG): $(OBJS)
$(LINK64.c) -o $@ $(OBJS) $(LDLIBS)
$(POST_PROCESS)

clean:
-$(RM) $(CLEANFILES)

%.o: %.c
$(COMPILE64.c) $<
$(POST_PROCESS_O)

clobber: clean
$(RM) $(PROG)

install: $(PROG) $(ROOTUSRSBINPROG)

FRC:

include ../Makefile.targ
Loading