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

Function route_output

freebsd/net/rtsock.c:988–1182  ·  view source on GitHub ↗

ARGSUSED*/

Source from the content-addressed store, hash-verified

986
987/*ARGSUSED*/
988static int
989route_output(struct mbuf *m, struct socket *so, ...)
990{
991 struct rt_msghdr *rtm = NULL;
992 struct rtentry *rt = NULL;
993 struct rt_addrinfo info;
994 struct epoch_tracker et;
995#ifdef INET6
996 struct sockaddr_storage ss;
997 struct sockaddr_in6 *sin6;
998 int i, rti_need_deembed = 0;
999#endif
1000 int alloc_len = 0, len, error = 0, fibnum;
1001 sa_family_t saf = AF_UNSPEC;
1002 struct rib_cmd_info rc;
1003 struct nhop_object *nh;
1004
1005 fibnum = so->so_fibnum;
1006#define senderr(e) { error = e; goto flush;}
1007 if (m == NULL || ((m->m_len < sizeof(long)) &&
1008 (m = m_pullup(m, sizeof(long))) == NULL))
1009 return (ENOBUFS);
1010 if ((m->m_flags & M_PKTHDR) == 0)
1011 panic("route_output");
1012 NET_EPOCH_ENTER(et);
1013 len = m->m_pkthdr.len;
1014 if (len < sizeof(*rtm) ||
1015 len != mtod(m, struct rt_msghdr *)->rtm_msglen)
1016 senderr(EINVAL);
1017
1018 /*
1019 * Most of current messages are in range 200-240 bytes,
1020 * minimize possible re-allocation on reply using larger size
1021 * buffer aligned on 1k boundaty.
1022 */
1023 alloc_len = roundup2(len, 1024);
1024 if ((rtm = malloc(alloc_len, M_TEMP, M_NOWAIT)) == NULL)
1025 senderr(ENOBUFS);
1026
1027 m_copydata(m, 0, len, (caddr_t)rtm);
1028 bzero(&info, sizeof(info));
1029 nh = NULL;
1030
1031 if (rtm->rtm_version != RTM_VERSION) {
1032 /* Do not touch message since format is unknown */
1033 free(rtm, M_TEMP);
1034 rtm = NULL;
1035 senderr(EPROTONOSUPPORT);
1036 }
1037
1038 /*
1039 * Starting from here, it is possible
1040 * to alter original message and insert
1041 * caller PID and error value.
1042 */
1043
1044 if ((error = fill_addrinfo(rtm, len, fibnum, &info)) != 0) {
1045 senderr(error);

Callers

nothing calls this directly

Calls 15

m_pullupFunction · 0.85
mallocFunction · 0.85
m_copydataFunction · 0.85
bzeroFunction · 0.85
lla_rt_outputFunction · 0.85
rib_actionFunction · 0.85
nhop_get_rtflagsFunction · 0.85
sa6_recoverscopeFunction · 0.85
send_rtm_replyFunction · 0.85
fill_addrinfoFunction · 0.70
fill_blackholeinfoFunction · 0.70

Tested by

no test coverage detected