MCPcopy Create free account
hub / github.com/F-Stack/f-stack / nhgrp_dump_sysctl

Function nhgrp_dump_sysctl

freebsd/net/route/nhgrp_ctl.c:792–824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

790}
791
792int
793nhgrp_dump_sysctl(struct rib_head *rh, struct sysctl_req *w)
794{
795 struct nh_control *ctl = rh->nh_control;
796 struct epoch_tracker et;
797 struct nhgrp_priv *nhg_priv;
798 char *buffer;
799 size_t sz;
800 int error = 0;
801
802 if (ctl->gr_head.items_count == 0)
803 return (0);
804
805 /* Calculate the maximum nhop group size in bytes */
806 sz = sizeof(struct rt_msghdr) + sizeof(struct nhgrp_external);
807 sz += 2 * sizeof(struct nhgrp_container);
808 sz += 2 * sizeof(struct nhgrp_nhop_external) * RIB_MAX_MPATH_WIDTH;
809 buffer = malloc(sz, M_TEMP, M_WAITOK);
810
811 NET_EPOCH_ENTER(et);
812 NHOPS_RLOCK(ctl);
813 CHT_SLIST_FOREACH(&ctl->gr_head, mpath, nhg_priv) {
814 error = dump_nhgrp_entry(rh, nhg_priv, buffer, sz, w);
815 if (error != 0)
816 break;
817 } CHT_SLIST_FOREACH_END;
818 NHOPS_RUNLOCK(ctl);
819 NET_EPOCH_EXIT(et);
820
821 free(buffer, M_TEMP);
822
823 return (error);
824}

Callers 1

sysctl_rtsockFunction · 0.85

Calls 3

mallocFunction · 0.85
dump_nhgrp_entryFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected