Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsclient/nfs_clvfsops.c
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | |||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <vm/vm.h> | #include <vm/vm.h> | ||||
#include <vm/vm_extern.h> | #include <vm/vm_extern.h> | ||||
#include <vm/uma.h> | #include <vm/uma.h> | ||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route/route_ctl.h> | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <fs/nfs/nfsport.h> | #include <fs/nfs/nfsport.h> | ||||
#include <fs/nfsclient/nfsnode.h> | #include <fs/nfsclient/nfsnode.h> | ||||
#include <fs/nfsclient/nfsmount.h> | #include <fs/nfsclient/nfsmount.h> | ||||
#include <fs/nfsclient/nfs.h> | #include <fs/nfsclient/nfs.h> | ||||
#include <nfs/nfsdiskless.h> | #include <nfs/nfsdiskless.h> | ||||
▲ Show 20 Lines • Show All 382 Lines • ▼ Show 20 Lines | #endif | ||||
* Note that pxeboot will set a default route of 0 if the route | * Note that pxeboot will set a default route of 0 if the route | ||||
* is not set by the DHCP server. Check also for a value of 0 | * is not set by the DHCP server. Check also for a value of 0 | ||||
* to avoid panicking inappropriately in that situation. | * to avoid panicking inappropriately in that situation. | ||||
*/ | */ | ||||
if (nd->mygateway.sin_len != 0 && | if (nd->mygateway.sin_len != 0 && | ||||
nd->mygateway.sin_addr.s_addr != 0) { | nd->mygateway.sin_addr.s_addr != 0) { | ||||
struct sockaddr_in mask, sin; | struct sockaddr_in mask, sin; | ||||
struct epoch_tracker et; | struct epoch_tracker et; | ||||
struct rt_addrinfo info; | |||||
donner: info is not initialized here.
I'd recommend to do a in-place initialization here (violating… | |||||
ncAuthorUnsubmitted Done Inline ActionsHowever, we use things like info.rti_info[RTAX_DST] which I'm not sure if it can be statically assigned. nc: However, we use things like `info.rti_info[RTAX_DST]` which I'm not sure if it can be… | |||||
struct rib_cmd_info rc; | |||||
bzero((caddr_t)&mask, sizeof(mask)); | bzero((caddr_t)&mask, sizeof(mask)); | ||||
sin = mask; | sin = mask; | ||||
sin.sin_family = AF_INET; | sin.sin_family = AF_INET; | ||||
sin.sin_len = sizeof(sin); | sin.sin_len = sizeof(sin); | ||||
donnerUnsubmitted Done Inline ActionsTo explain the comment above about struct initialization here. struct sockaddr_in mask = {}; struct sockaddr_in sin = { .sin_family = AF_INET, .sin_len = sizeof(sin) }; donner: To explain the comment above about struct initialization here.
struct sockaddr_in mask = {}… | |||||
/* XXX MRT use table 0 for this sort of thing */ | /* XXX MRT use table 0 for this sort of thing */ | ||||
NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||
CURVNET_SET(TD_TO_VNET(td)); | CURVNET_SET(TD_TO_VNET(td)); | ||||
error = rtrequest_fib(RTM_ADD, (struct sockaddr *)&sin, | |||||
(struct sockaddr *)&nd->mygateway, | info.rti_flags = RTF_UP | RTF_GATEWAY; | ||||
(struct sockaddr *)&mask, | info.rti_info[RTAX_DST] = (struct sockaddr *)&sin; | ||||
RTF_UP | RTF_GATEWAY, NULL, RT_DEFAULT_FIB); | info.rti_info[RTAX_GATEWAY] = (struct sockaddr *)&nd->mygateway; | ||||
info.rti_info[RTAX_NETMASK] = (struct sockaddr *)&mask; | |||||
error = rib_action(RT_DEFAULT_FIB, RTM_ADD, &info, &rc); | |||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
NET_EPOCH_EXIT(et); | NET_EPOCH_EXIT(et); | ||||
if (error) | if (error) | ||||
panic("nfs_mountroot: RTM_ADD: %d", error); | panic("nfs_mountroot: RTM_ADD: %d", error); | ||||
} | } | ||||
/* | /* | ||||
* Create the rootfs mount point. | * Create the rootfs mount point. | ||||
▲ Show 20 Lines • Show All 1,566 Lines • Show Last 20 Lines |
info is not initialized here.
I'd recommend to do a in-place initialization here (violating style(9)) for the statically defined field .rti_flags, which implicitly zeroes all other fields.
https://en.cppreference.com/w/c/language/struct_initialization