Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
| Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||||||
| #include <netinet/in_var.h> | #include <netinet/in_var.h> | ||||||||
| #include <netinet/in_pcb.h> | #include <netinet/in_pcb.h> | ||||||||
| #include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||||||
| #include <netinet/ip_carp.h> | #include <netinet/ip_carp.h> | ||||||||
| #include <netinet/igmp_var.h> | #include <netinet/igmp_var.h> | ||||||||
| #include <netinet/udp.h> | #include <netinet/udp.h> | ||||||||
| #include <netinet/udp_var.h> | #include <netinet/udp_var.h> | ||||||||
| #ifdef MAC | |||||||||
bz: We only need to include this if MAC is defined, so hiding it behind #ifdef will avoid header… | |||||||||
| #include <security/mac/mac_framework.h> | |||||||||
| #endif | |||||||||
| static int in_aifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | static int in_aifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | ||||||||
| static int in_difaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | static int in_difaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | ||||||||
| static int in_gifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | static int in_gifaddr_ioctl(u_long, caddr_t, struct ifnet *, struct ucred *); | ||||||||
| static void in_socktrim(struct sockaddr_in *); | static void in_socktrim(struct sockaddr_in *); | ||||||||
| static void in_purgemaddrs(struct ifnet *); | static void in_purgemaddrs(struct ifnet *); | ||||||||
| static bool ia_need_loopback_route(const struct in_ifaddr *); | static bool ia_need_loopback_route(const struct in_ifaddr *); | ||||||||
| ▲ Show 20 Lines • Show All 393 Lines • ▼ Show 20 Lines | if (mask->sin_len != 0 && | ||||||||
| mask->sin_family != AF_INET)) | mask->sin_family != AF_INET)) | ||||||||
| return (EINVAL); | return (EINVAL); | ||||||||
| if ((ifp->if_flags & IFF_POINTOPOINT) && | if ((ifp->if_flags & IFF_POINTOPOINT) && | ||||||||
| (dstaddr->sin_len != sizeof(struct sockaddr_in) || | (dstaddr->sin_len != sizeof(struct sockaddr_in) || | ||||||||
| dstaddr->sin_addr.s_addr == INADDR_ANY)) | dstaddr->sin_addr.s_addr == INADDR_ANY)) | ||||||||
| return (EDESTADDRREQ); | return (EDESTADDRREQ); | ||||||||
| if (vhid != 0 && carp_attach_p == NULL) | if (vhid != 0 && carp_attach_p == NULL) | ||||||||
| return (EPROTONOSUPPORT); | return (EPROTONOSUPPORT); | ||||||||
| #ifdef MAC | |||||||||
| /* Check if a MAC policy disallows setting the IPv4 address. */ | |||||||||
| error = mac_inet_check_add_addr(cred, &addr->sin_addr, ifp); | |||||||||
| if (error != 0) | |||||||||
Done Inline Actions
melifaro: | |||||||||
| return (error); | |||||||||
| #endif | |||||||||
| /* | /* | ||||||||
| * See whether address already exist. | * See whether address already exist. | ||||||||
| */ | */ | ||||||||
| iaIsFirst = true; | iaIsFirst = true; | ||||||||
| ia = NULL; | ia = NULL; | ||||||||
| NET_EPOCH_ENTER(et); | NET_EPOCH_ENTER(et); | ||||||||
Done Inline ActionsDo whitespace /*<space>...<space>*/ still fit on 80 chars? (also for ipv6 and the other files) bz: Do whitespace /*<space>...<space>*/ still fit on 80 chars?
(also for ipv6 and the other files) | |||||||||
| CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | CK_STAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | ||||||||
| struct in_ifaddr *it; | struct in_ifaddr *it; | ||||||||
Done Inline ActionsComments start upper case and use punctuation. Also the comment could move inside the ifdef block. bz: Comments start upper case and use punctuation. Also the comment could move inside the ifdef… | |||||||||
| if (ifa->ifa_addr->sa_family != AF_INET) | if (ifa->ifa_addr->sa_family != AF_INET) | ||||||||
Done Inline ActionsLines should wrap at latest at 80 characters. Tabs are 8 spaces in FreeBSD. Indentation by tab to the same level and four spaces. bz: Lines should wrap at latest at 80 characters. Tabs are 8 spaces in FreeBSD. Indentation by… | |||||||||
| continue; | continue; | ||||||||
Done Inline ActionsNo need for { }; removing them will save vertical space (an extra line) bz: No need for { }; removing them will save vertical space (an extra line) | |||||||||
| it = (struct in_ifaddr *)ifa; | it = (struct in_ifaddr *)ifa; | ||||||||
| if (it->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr && | if (it->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr && | ||||||||
| prison_check_ip4(cred, &addr->sin_addr) == 0) | prison_check_ip4(cred, &addr->sin_addr) == 0) | ||||||||
| ia = it; | ia = it; | ||||||||
| else | else | ||||||||
| iaIsFirst = false; | iaIsFirst = false; | ||||||||
| } | } | ||||||||
| ▲ Show 20 Lines • Show All 1,350 Lines • Show Last 20 Lines | |||||||||
We only need to include this if MAC is defined, so hiding it behind #ifdef will avoid header dependencies if MAC is not compiled into the kernel.