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

Function rt_setup_rate

freebsd/netinet/tcp_ratelimit.c:1025–1121  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1023}
1024
1025static const struct tcp_hwrate_limit_table *
1026rt_setup_rate(struct inpcb *inp, struct ifnet *ifp, uint64_t bytes_per_sec,
1027 uint32_t flags, int *error)
1028{
1029 /* First lets find the interface if it exists */
1030 const struct tcp_hwrate_limit_table *rte;
1031 struct tcp_rate_set *rs;
1032 struct epoch_tracker et;
1033 int err;
1034
1035 NET_EPOCH_ENTER(et);
1036use_real_interface:
1037 CK_LIST_FOREACH(rs, &int_rs, next) {
1038 /*
1039 * Note we don't look with the lock since we either see a
1040 * new entry or will get one when we try to add it.
1041 */
1042 if (rs->rs_flags & RS_IS_DEAD) {
1043 /* The dead are not looked at */
1044 continue;
1045 }
1046 if ((rs->rs_ifp == ifp) &&
1047 (rs->rs_if_dunit == ifp->if_dunit)) {
1048 /* Ok we found it */
1049 break;
1050 }
1051 }
1052 if ((rs == NULL) ||
1053 (rs->rs_flags & RS_INTF_NO_SUP) ||
1054 (rs->rs_flags & RS_IS_DEAD)) {
1055 /*
1056 * This means we got a packet *before*
1057 * the IF-UP was processed below, <or>
1058 * while or after we already received an interface
1059 * departed event. In either case we really don't
1060 * want to do anything with pacing, in
1061 * the departing case the packet is not
1062 * going to go very far. The new case
1063 * might be arguable, but its impossible
1064 * to tell from the departing case.
1065 */
1066 if (rs->rs_disable && error)
1067 *error = ENODEV;
1068 NET_EPOCH_EXIT(et);
1069 return (NULL);
1070 }
1071
1072 if ((rs == NULL) || (rs->rs_disable != 0)) {
1073 if (rs->rs_disable && error)
1074 *error = ENOSPC;
1075 NET_EPOCH_EXIT(et);
1076 return (NULL);
1077 }
1078 if (rs->rs_flags & RS_IS_DEFF) {
1079 /* We need to find the real interface */
1080 struct ifnet *tifp;
1081
1082 tifp = rt_find_real_interface(ifp, inp, error);

Callers 1

tcp_set_pacing_rateFunction · 0.85

Calls 4

rt_find_real_interfaceFunction · 0.85
tcp_find_suitable_rateFunction · 0.85
in_pcbattach_txrtlmtFunction · 0.85
atomic_add_64Function · 0.50

Tested by

no test coverage detected