Merge ^/head r288457 through r288830.

This commit is contained in:
dim 2015-10-05 17:54:54 +00:00
commit 1b28caab43
190 changed files with 3404 additions and 858 deletions

View File

@ -61,9 +61,6 @@ SUBDIR= ${SUBDIR_OVERRIDE}
.else
SUBDIR= lib libexec
SUBDIR+=bin
.if ${MK_GAMES} != "no"
SUBDIR+=games
.endif
.if ${MK_CDDL} != "no"
SUBDIR+=cddl
.endif
@ -1285,7 +1282,7 @@ legacy:
_bt= _bootstrap-tools
.if ${MK_GAMES} != "no"
_strfile= games/fortune/strfile
_strfile= usr.bin/fortune/strfile
.endif
.if ${MK_GCC} != "no" && ${MK_CXX} != "no"
@ -1325,6 +1322,8 @@ _cat= bin/cat
.if ${BOOTSTRAPPING} < 1000033
_lex= usr.bin/lex
${_bt}-usr.bin/lex: ${_bt}-usr.bin/m4
.endif
# r277259 crunchide: Correct 64-bit section header offset

View File

@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <netdb.h>
#endif
#include <ctype.h>
@ -167,6 +168,7 @@ scanfiles(char *argv[], int cooked)
FILE *fp;
i = 0;
fd = -1;
while ((path = argv[i]) != NULL || i == 0) {
if (path == NULL || strcmp(path, "-") == 0) {
filename = "stdin";
@ -302,31 +304,40 @@ raw_cat(int rfd)
static int
udom_open(const char *path, int flags)
{
struct sockaddr_un sou;
int fd;
unsigned int len;
bzero(&sou, sizeof(sou));
struct addrinfo hints, *res, *res0;
char rpath[PATH_MAX];
int fd = -1;
int error;
/*
* Construct the unix domain socket address and attempt to connect
* Construct the unix domain socket address and attempt to connect.
*/
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd >= 0) {
sou.sun_family = AF_UNIX;
if ((len = strlcpy(sou.sun_path, path,
sizeof(sou.sun_path))) >= sizeof(sou.sun_path)) {
close(fd);
errno = ENAMETOOLONG;
bzero(&hints, sizeof(hints));
hints.ai_family = AF_LOCAL;
if (realpath(path, rpath) == NULL)
return (-1);
error = getaddrinfo(rpath, NULL, &hints, &res0);
if (error) {
warn("%s", gai_strerror(error));
errno = EINVAL;
return (-1);
}
for (res = res0; res != NULL; res = res->ai_next) {
fd = socket(res->ai_family, res->ai_socktype,
res->ai_protocol);
if (fd < 0) {
freeaddrinfo(res0);
return (-1);
}
len = offsetof(struct sockaddr_un, sun_path[len+1]);
if (connect(fd, (void *)&sou, len) < 0) {
error = connect(fd, res->ai_addr, res->ai_addrlen);
if (error == 0)
break;
else {
close(fd);
fd = -1;
}
}
freeaddrinfo(res0);
/*
* handle the open flags by shutting down appropriate directions

View File

@ -6,6 +6,6 @@ ATF_TESTS_SH+= ls_tests
# This seems like overkill, but the idea in mind is that all of the testcases
# should be runnable as !root
TEST_METADATA.ls_tests+= required_user="unprivileged"
TEST_METADATA.ls_tests+= required_files="/usr/bin/nc"
TEST_METADATA.ls_tests+= required_files="/usr/bin/awk /usr/bin/nc /usr/bin/sort"
.include <bsd.test.mk>

View File

@ -45,7 +45,7 @@ create_test_inputs()
{
create_test_dir
atf_check -e empty -s exit:0 mkdir -m 0755 -p a/b
atf_check -e empty -s exit:0 mkdir -m 0755 -p a/b/1
atf_check -e empty -s exit:0 ln -s a/b c
atf_check -e empty -s exit:0 touch d
atf_check -e empty -s exit:0 ln d e
@ -53,12 +53,10 @@ create_test_inputs()
atf_check -e empty -s exit:0 mkdir .g
atf_check -e empty -s exit:0 mkfifo h
atf_check -e ignore -s exit:0 dd if=/dev/zero of=i count=1000 bs=1
atf_check -e empty -s exit:0 \
sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid"
atf_check -e empty -s exit:0 touch klmn
atf_check -e empty -s exit:0 touch opqr
atf_check -e empty -s exit:0 touch stuv
atf_check -e empty -s exit:0 touch wxyz
atf_check -e empty -s exit:0 install -m 0755 /dev/null wxyz
atf_check -e empty -s exit:0 touch 0b00000001
atf_check -e empty -s exit:0 touch 0b00000010
atf_check -e empty -s exit:0 touch 0b00000011
@ -76,37 +74,29 @@ create_test_inputs()
atf_check -e empty -s exit:0 touch 0b00001111
}
atf_test_case a_flag
a_flag_head()
{
atf_set "descr" "Verify -a support"
}
KB=1024
MB=$(( 1024 * $KB ))
GB=$(( 1024 * $MB ))
TB=$(( 1024 * $GB ))
PB=$(( 1024 * $TB ))
a_flag_body()
create_test_inputs2()
{
create_test_dir
# Make sure "." and ".." show up with -a
atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax
for filesize in 1 512 $(( 2 * $KB )) $(( 10 * $KB )) $(( 512 * $KB )); \
do
atf_check -e ignore -o empty -s exit:0 \
dd if=/dev/zero of=${filesize}.file bs=1 \
count=1 oseek=${filesize} conv=sparse
files="${files} ${filesize}.file"
done
create_test_inputs
WITH_a=$PWD/../with_a.out
WITHOUT_a=$PWD/../without_a.out
atf_check -e empty -o save:$WITH_a -s exit:0 ls -A
atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls
echo "-A usage"
cat $WITH_a
echo "No -A usage"
cat $WITHOUT_a
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_a
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_a
for filesize in $MB $GB $TB; do
atf_check -e ignore -o empty -s exit:0 \
dd if=/dev/zero of=${filesize}.file bs=$MB \
count=1 oseek=$(( $filesize / $MB )) conv=sparse
files="${files} ${filesize}.file"
done
}
@ -192,21 +182,101 @@ C_flag_head()
atf_set "descr" "Verify that the output from ls -C is multi-column, sorted down"
}
print_index()
{
local i=1
local wanted_index=$1; shift
while [ $i -le $wanted_index ]; do
if [ $i -eq $wanted_index ]; then
echo $1
return
fi
shift
: $(( i += 1 ))
done
}
C_flag_body()
{
create_test_inputs
WITH_C=$PWD/../with_C.out
export COLUMNS=40
atf_check -e empty -o save:$WITH_C -s exit:0 ls -C
echo "With -C usage"
cat $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000001[[:space:]]+0b00000111[[:space:]]+0b00001101[[:space:]]+e[[:space:]]+stuv" $WITH_C
atf_check -e ignore -o not-empty -s exit:0 \
egrep "0b00000010[[:space:]]+0b00001000[[:space:]]+0b00001110[[:space:]]+h[[:space:]]+wxyz" $WITH_C
paths=$(find -s . -mindepth 1 -maxdepth 1 \! -name '.*' -exec basename {} \; )
set -- $paths
num_paths=$#
num_columns=2
max_num_paths_per_column=$(( $(( $num_paths + 1 )) / $num_columns ))
local i=1
while [ $i -le $max_num_paths_per_column ]; do
column_1=$(print_index $i $paths)
column_2=$(print_index $(( $i + $max_num_paths_per_column )) $paths)
#echo "paths[$(( $i + $max_num_paths_per_column ))] = $column_2"
expected_expr="$column_1"
if [ -n "$column_2" ]; then
expected_expr="$expected_expr[[:space:]]+$column_2"
fi
atf_check -e ignore -o not-empty -s exit:0 \
egrep "$expected_expr" $WITH_C
: $(( i += 1 ))
done
}
atf_test_case D_flag
D_flag_head()
{
atf_set "descr" "Verify that the output from ls -D modifies the time format used with ls -l"
}
D_flag_body()
{
atf_check -e empty -o empty -s exit:0 touch a.file
atf_check -e empty -o match:"$(stat -f '%c[[:space:]]+%N' a.file)" \
-s exit:0 ls -lD '%s'
}
atf_test_case F_flag
F_flag_head()
{
atf_set "descr" "Verify that the output from ls -F prints out appropriate symbols after files"
}
F_flag_body()
{
create_test_inputs
atf_check -e empty -s exit:0 \
sh -c "pid=${ATF_TMPDIR}/nc.pid; daemon -p \$pid nc -lU j; sleep 2; pkill -F \$pid"
atf_check -e empty -o match:'a/' -s exit:0 ls -F
atf_check -e empty -o match:'c@' -s exit:0 ls -F
atf_check -e empty -o match:'h\|' -s exit:0 ls -F
atf_check -e empty -o match:'j=' -s exit:0 ls -F
#atf_check -e empty -o match:'<whiteout-file>%' -s exit:0 ls -F
atf_check -e empty -o match:'stuv' -s exit:0 ls -F
atf_check -e empty -o match:'wxyz\*' -s exit:0 ls -F
}
atf_test_case H_flag
H_flag_head()
{
atf_set "descr" "Verify that ls -H follows symlinks"
}
H_flag_body()
{
create_test_inputs
atf_check -e empty -o match:'1' -s exit:0 ls -H c
}
atf_test_case I_flag
@ -251,9 +321,323 @@ I_flag_voids_implied_A_flag_when_root_body()
atf_check -o match:'\.g' -s exit:0 ls -A -I
}
atf_test_case L_flag
L_flag_head()
{
atf_set "descr" "Verify that -L prints out the symbolic link and conversely -P prints out the target for the symbolic link"
}
L_flag_body()
{
atf_check -e empty -o empty -s exit:0 ln -s target1/target2 link1
atf_check -e empty -o match:link1 -s exit:0 ls -L
atf_check -e empty -o not-match:target1/target2 -s exit:0 ls -L
}
atf_test_case R_flag
R_flag_head()
{
atf_set "descr" "Verify that the output from ls -R prints out the directory contents recursively"
}
R_flag_body()
{
create_test_inputs
WITH_R=$PWD/../with_R.out
WITH_R_expected_output=$PWD/../with_R_expected.out
atf_check -e empty -o save:$WITH_R -s exit:0 ls -R
set -- . $(find -s . \! -name '.*' -type d)
while [ $# -gt 0 ]; do
dir=$1; shift
[ "$dir" != "." ] && echo "$dir:"
(cd $dir && ls -1A | sed -e '/^\./d')
[ $# -ne 0 ] && echo
done > $WITH_R_expected_output
echo "-R usage"
cat $WITH_R
echo "-R expected output"
cat $WITH_R_expected_output
atf_check_equal "$(cat $WITH_R)" "$(cat $WITH_R_expected_output)"
}
atf_test_case S_flag
S_flag_head()
{
atf_set "descr" "Verify that -S sorts by file size, then by filename lexicographically"
}
S_flag_body()
{
create_test_dir
file_list_dir=$PWD/../files
atf_check -e empty -o empty -s exit:0 mkdir -p $file_list_dir
create_test_inputs
create_test_inputs2
WITH_S=$PWD/../with_S.out
WITHOUT_S=$PWD/../without_S.out
atf_check -e empty -o save:$WITH_S ls -D '%s' -lS
atf_check -e empty -o save:$WITHOUT_S ls -D '%s' -l
WITH_S_parsed=$(awk '! /^total/ { print $7 }' $WITH_S)
set -- $(awk '! /^total/ { print $5, $7 }' $WITHOUT_S)
while [ $# -gt 0 ]; do
size=$1; shift
filename=$1; shift
echo $filename >> $file_list_dir/${size}
done
file_lists=$(find $file_list_dir -type f -exec basename {} \; | sort -nr)
WITHOUT_S_parsed=$(for file_list in $file_lists; do sort < $file_list_dir/$file_list; done)
echo "-lS usage (parsed)"
echo "$WITH_S_parsed"
echo "-l usage (parsed)"
echo "$WITHOUT_S_parsed"
atf_check_equal "$WITHOUT_S_parsed" "$WITH_S_parsed"
}
atf_test_case T_flag
T_flag_head()
{
atf_set "descr" "Verify -T support"
}
T_flag_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 touch a.file
birthtime_in_secs=$(stat -f %B -t %s a.file)
birthtime=$(date -j -f %s $birthtime_in_secs +"[[:space:]]+%b[[:space:]]+%e[[:space:]]+%H:%M:%S[[:space:]]+%Y")
atf_check -e empty -o match:"$birthtime"'[[:space:]]+a\.file' \
-s exit:0 ls -lT a.file
}
atf_test_case a_flag
a_flag_head()
{
atf_set "descr" "Verify -a support"
}
a_flag_body()
{
create_test_dir
# Make sure "." and ".." show up with -a
atf_check -e empty -o match:'\.[[:space:]]+\.\.' -s exit:0 ls -ax
create_test_inputs
WITH_a=$PWD/../with_a.out
WITHOUT_a=$PWD/../without_a.out
atf_check -e empty -o save:$WITH_a -s exit:0 ls -a
atf_check -e empty -o save:$WITHOUT_a -s exit:0 ls
echo "-a usage"
cat $WITH_a
echo "No -a usage"
cat $WITHOUT_a
for dot_path in '\.f' '\.g'; do
atf_check -e empty -o not-empty -s exit:0 grep "${dot_path}" \
$WITH_a
atf_check -e empty -o empty -s not-exit:0 grep "${dot_path}" \
$WITHOUT_a
done
}
atf_test_case b_flag
b_flag_head()
{
atf_set "descr" "Verify that the output from ls -b prints out non-printable characters"
}
b_flag_body()
{
atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136"
atf_check -e empty -o empty -s exit:0 touch "$(printf "y\013z")"
atf_check -e empty -o match:'y\\vz' -s exit:0 ls -b
}
atf_test_case d_flag
d_flag_head()
{
atf_set "descr" "Verify that -d doesn't descend down directories"
}
d_flag_body()
{
create_test_dir
output=$PWD/../output
atf_check -e empty -o empty -s exit:0 mkdir -p a/b
for path in . $PWD a; do
atf_check -e empty -o save:$output -s exit:0 ls -d $path
atf_check_equal "$(cat $output)" "$path"
done
}
atf_test_case f_flag
f_flag_head()
{
atf_set "descr" "Verify that -f prints out the contents of a directory unsorted"
}
f_flag_body()
{
create_test_inputs
output=$PWD/../output
# XXX: I don't have enough understanding of how the algorithm works yet
# to determine more than the fact that all the entries printed out
# exist
paths=$(find -s . -mindepth 1 -maxdepth 1 \! -name '.*' -exec basename {} \; )
atf_check -e empty -o save:$output -s exit:0 ls -f
for path in $paths; do
atf_check -e ignore -o not-empty -s exit:0 \
egrep "^$path$" $output
done
}
atf_test_case g_flag
g_flag_head()
{
atf_set "descr" "Verify that -g does nothing (compatibility flag)"
}
g_flag_body()
{
create_test_inputs2
for file in $files; do
atf_check -e empty -o match:"$(ls -a $file)" -s exit:0 \
ls -ag $file
atf_check -e empty -o match:"$(ls -la $file)" -s exit:0 \
ls -alg $file
done
}
atf_test_case h_flag
h_flag_head()
{
atf_set "descr" "Verify that -h prints out the humanized units for file sizes with ls -l"
atf_set "require.files" "/usr/bin/bc"
}
h_flag_body()
{
# XXX: this test doesn't currently show how 999 bytes will be 999B,
# but 1000 bytes will be 1.0K, due to how humanize_number(3) works.
create_test_inputs2
for file in $files; do
file_size=$(stat -f '%z' "$file") || \
atf_fail "stat'ing $file failed"
scale=2
if [ $file_size -lt $KB ]; then
divisor=1
scale=0
suffix=B
elif [ $file_size -lt $MB ]; then
divisor=$KB
suffix=K
elif [ $file_size -lt $GB ]; then
divisor=$MB
suffix=M
elif [ $file_size -lt $TB ]; then
divisor=$GB
suffix=G
elif [ $file_size -lt $PB ]; then
divisor=$TB
suffix=T
else
divisor=$PB
suffix=P
fi
bc_expr="$(printf "scale=%s\n%s/%s\nquit" $scale $file_size $divisor)"
size_humanized=$(bc -e "$bc_expr" | tr '.' '\.' | sed -e 's,\.00,,')
atf_check -e empty -o match:"$size_humanized.+$file" \
-s exit:0 ls -hl $file
done
}
atf_test_case i_flag
i_flag_head()
{
atf_set "descr" "Verify that -i prints out the inode for files"
}
i_flag_body()
{
create_test_inputs
paths=$(find -L . -mindepth 1)
[ -n "$paths" ] || atf_skip 'Could not find any paths to iterate over (!)'
for path in $paths; do
atf_check -e empty \
-o match:"$(stat -f '[[:space:]]*%i[[:space:]]+%N' $path)" \
-s exit:0 ls -d1i $path
done
}
atf_test_case k_flag
k_flag_head()
{
atf_set "descr" "Verify that -k prints out the size with a block size of 1kB"
}
k_flag_body()
{
create_test_inputs2
for file in $files; do
atf_check -e empty \
-o match:"[[:space:]]+$(stat -f "%z" $file)[[:space:]]+.+[[:space:]]+$file" ls -lk $file
done
}
atf_test_case l_flag
l_flag_head()
{
atf_set "descr" "Verify that -l prints out the output in long format"
}
l_flag_body()
{
atf_check -e empty -o empty -s exit:0 touch a.file
birthtime_in_secs=$(stat -f "%B" -t "%s" a.file)
birthtime=$(date -j -f "%s" $birthtime_in_secs +"%b[[:space:]]+%e[[:space:]]+%H:%M")
expected_output=$(stat -f "%Sp[[:space:]]+%l[[:space:]]+%Su[[:space:]]+%Sg[[:space:]]+%z[[:space:]]+$birthtime[[:space:]]+a\\.file" a.file)
atf_check -e empty -o match:"$expected_output" -s exit:0 ls -l a.file
}
atf_test_case lcomma_flag
lcomma_flag_head()
{
atf_set "descr" "Verify that -l, prints out the size with , delimiters"
atf_set "descr" "Verify that -l, prints out the size with ',' delimiters"
}
lcomma_flag_body()
@ -265,9 +649,211 @@ lcomma_flag_body()
env LC_ALL=en_US.ISO8859-1 ls -l, i
}
atf_test_case m_flag
m_flag_head()
{
atf_set "descr" "Verify that the output from ls -m is comma-separated"
}
m_flag_body()
{
create_test_dir
output=$PWD/../output
atf_check -e empty -o empty -s exit:0 touch ,, "a,b " c d e
atf_check -e empty -o save:$output -s exit:0 ls -m
atf_check_equal "$(cat $output)" ",,, a,b , c, d, e"
}
atf_test_case n_flag
n_flag_head()
{
atf_set "descr" "Verify that the output from ls -n prints out numeric GIDs/UIDs instead of symbolic GIDs/UIDs"
atf_set "require.user" "root"
}
n_flag_body()
{
daemon_gid=$(id -g daemon) || atf_skip "could not resolve gid for daemon (!)"
nobody_uid=$(id -u nobody) || atf_skip "could not resolve uid for nobody (!)"
atf_check -e empty -o empty -s exit:0 touch a.file
atf_check -e empty -o empty -s exit:0 chown $nobody_uid:$daemon_gid a.file
atf_check -e empty \
-o match:'\-rw\-r\-\-r\-\-[[:space:]]+1[[:space:]]+'"$nobody_uid[[:space:]]+$daemon_gid"'[[:space:]]+.+a\.file' \
ls -ln a.file
}
atf_test_case o_flag
o_flag_head()
{
atf_set "descr" "Verify that the output from ls -o prints out the chflag values or '-' if none are set"
atf_set "require.user" "root"
}
o_flag_body()
{
local size=12345
create_test_dir
atf_check -e ignore -o empty -s exit:0 dd if=/dev/zero of=a.file \
bs=$size count=1
atf_check -e ignore -o empty -s exit:0 dd if=/dev/zero of=b.file \
bs=$size count=1
atf_check -e empty -o empty -s exit:0 chflags uarch a.file
atf_check -e empty -o match:"[[:space:]]+uarch[[:space:]]$size+.+a\\.file" \
-s exit:0 ls -lo a.file
atf_check -e empty -o match:"[[:space:]]+\\-[[:space:]]$size+.+b\\.file" \
-s exit:0 ls -lo b.file
}
atf_test_case p_flag
p_flag_head()
{
atf_set "descr" "Verify that the output from ls -p prints out '/' after directories"
}
p_flag_body()
{
create_test_inputs
paths=$(find -L .)
[ -n "$paths" ] || atf_skip 'Could not find any paths to iterate over (!)'
for path in $paths; do
suffix=
# If path is not a symlink and is a directory, then the suffix
# must be "/".
if [ ! -L "${path}" -a -d "$path" ]; then
suffix=/
fi
atf_check -e empty -o match:"$path${suffix}" -s exit:0 \
ls -dp $path
done
}
atf_test_case q_flag_and_w_flag
q_flag_and_w_flag_head()
{
atf_set "descr" "Verify that the output from ls -q prints out '?' for ESC and ls -w prints out the escape character"
}
q_flag_and_w_flag_body()
{
atf_skip "kyua report-jenkins doesn't properly escape non-printable chars: https://github.com/jmmv/kyua/issues/136"
create_test_dir
test_file="$(printf "y\01z")"
atf_check -e empty -o empty -s exit:0 touch "$test_file"
atf_check -e empty -o match:'y\?z' -s exit:0 ls -q "$test_file"
atf_check -e empty -o match:"$test_file" -s exit:0 ls -w "$test_file"
}
atf_test_case r_flag
r_flag_head()
{
atf_set "descr" "Verify that the output from ls -r sorts the same way as reverse sorting with sort(1)"
}
r_flag_body()
{
create_test_inputs
WITH_r=$PWD/../with_r.out
WITH_sort=$PWD/../with_sort.out
atf_check -e empty -o save:$WITH_r -s exit:0 ls -1r
atf_check -e empty -o save:$WITH_sort -s exit:0 sh -c 'ls -1 | sort -r'
echo "Sorted with -r"
cat $WITH_r
echo "Reverse sorted with sort(1)"
cat $WITH_sort
atf_check_equal "$(cat $WITH_r)" "$(cat $WITH_sort)"
}
atf_test_case s_flag
s_flag_head()
{
atf_set "descr" "Verify that the output from ls -s matches the output from stat(1)"
}
s_flag_body()
{
create_test_inputs2
for file in $files; do
atf_check -e empty \
-o match:"$(stat -f "%b" $file)[[:space:]]+$file" ls -s $file
done
}
atf_test_case t_flag
t_flag_head()
{
atf_set "descr" "Verify that the output from ls -t sorts by modification time"
}
t_flag_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 touch a.file
atf_check -e empty -o empty -s exit:0 touch b.file
sync
atf_check -e empty -o match:'a\.file' -s exit:0 sh -c 'ls -lt | tail -n 1'
atf_check -e empty -o match:'b\.file.*a\.file' -s exit:0 ls -Ct
atf_check -e empty -o empty -s exit:0 rm a.file
atf_check -e empty -o empty -s exit:0 sh -c 'echo "i am a" > a.file'
sync
atf_check -e empty -o match:'b\.file' -s exit:0 sh -c 'ls -lt | tail -n 1'
atf_check -e empty -o match:'a\.file.*b\.file' -s exit:0 ls -Ct
}
atf_test_case u_flag
u_flag_head()
{
atf_set "descr" "Verify that the output from ls -u sorts by last access"
}
u_flag_body()
{
create_test_dir
atf_check -e empty -o empty -s exit:0 touch a.file
sync
atf_check -e empty -o empty -s exit:0 touch b.file
sync
atf_check -e empty -o match:'b\.file' -s exit:0 sh -c 'ls -lu | tail -n 1'
atf_check -e empty -o match:'a\.file.*b\.file' -s exit:0 ls -Cu
atf_check -e empty -o empty -s exit:0 sh -c 'echo "i am a" > a.file'
sync
atf_check -e empty -o match:'i am a' -s exit:0 cat a.file
sync
atf_check -e empty -o match:'b\.file' -s exit:0 sh -c 'ls -lu | tail -n 1'
atf_check -e empty -o match:'a\.file.*b\.file' -s exit:0 ls -Cu
}
atf_test_case x_flag
x_flag_head()
{
atf_set "descr" "Verify that -x prints out one item per line"
atf_set "descr" "Verify that the output from ls -x is multi-column, sorted across"
}
x_flag_body()
@ -284,9 +870,34 @@ x_flag_body()
atf_check -e ignore -o not-empty -s exit:0 \
egrep "a[[:space:]]+c[[:space:]]+d[[:space:]]+e[[:space:]]+h" $WITH_x
atf_check -e ignore -o not-empty -s exit:0 \
egrep "i[[:space:]]+j[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv" $WITH_x
egrep "i[[:space:]]+klmn[[:space:]]+opqr[[:space:]]+stuv[[:space:]]+wxyz" $WITH_x
}
atf_test_case y_flag
y_flag_head()
{
atf_set "descr" "Verify that the output from ls -y sorts the same way as sort(1)"
}
y_flag_body()
{
create_test_inputs
WITH_sort=$PWD/../with_sort.out
WITH_y=$PWD/../with_y.out
atf_check -e empty -o save:$WITH_sort -s exit:0 sh -c 'ls -1 | sort'
atf_check -e empty -o save:$WITH_y -s exit:0 ls -1y
echo "Sorted with sort(1)"
cat $WITH_sort
echo "Sorted with -y"
cat $WITH_y
atf_check_equal "$(cat $WITH_sort)" "$(cat $WITH_y)"
}
atf_test_case 1_flag
1_flag_head()
{
atf_set "descr" "Verify that -1 prints out one item per line"
@ -318,42 +929,41 @@ atf_init_test_cases()
atf_add_test_case A_flag_implied_when_root
atf_add_test_case B_flag
atf_add_test_case C_flag
#atf_add_test_case D_flag
#atf_add_test_case F_flag
atf_add_test_case D_flag
atf_add_test_case F_flag
#atf_add_test_case G_flag
#atf_add_test_case H_flag
atf_add_test_case H_flag
atf_add_test_case I_flag
atf_add_test_case I_flag_voids_implied_A_flag_when_root
#atf_add_test_case L_flag
atf_add_test_case L_flag
#atf_add_test_case P_flag
#atf_add_test_case R_flag
#atf_add_test_case S_flag
#atf_add_test_case T_flag
atf_add_test_case R_flag
atf_add_test_case S_flag
atf_add_test_case T_flag
#atf_add_test_case U_flag
#atf_add_test_case W_flag
#atf_add_test_case Z_flag
atf_add_test_case a_flag
#atf_add_test_case b_flag
atf_add_test_case b_flag
#atf_add_test_case c_flag
#atf_add_test_case d_flag
#atf_add_test_case f_flag
#atf_add_test_case g_flag
#atf_add_test_case h_flag
#atf_add_test_case i_flag
#atf_add_test_case k_flag
#atf_add_test_case l_flag
atf_add_test_case d_flag
atf_add_test_case f_flag
atf_add_test_case g_flag
atf_add_test_case h_flag
atf_add_test_case i_flag
atf_add_test_case k_flag
atf_add_test_case l_flag
atf_add_test_case lcomma_flag
#atf_add_test_case m_flag
#atf_add_test_case n_flag
#atf_add_test_case o_flag
#atf_add_test_case p_flag
#atf_add_test_case q_flag
#atf_add_test_case r_flag
#atf_add_test_case s_flag
#atf_add_test_case t_flag
#atf_add_test_case u_flag
#atf_add_test_case w_flag
atf_add_test_case m_flag
atf_add_test_case n_flag
atf_add_test_case o_flag
atf_add_test_case p_flag
atf_add_test_case q_flag_and_w_flag
atf_add_test_case r_flag
atf_add_test_case s_flag
atf_add_test_case t_flag
atf_add_test_case u_flag
atf_add_test_case x_flag
#atf_add_test_case y_flag
atf_add_test_case y_flag
atf_add_test_case 1_flag
}

View File

@ -1,21 +0,0 @@
# $FreeBSD$
.include <src.opts.mk>
SUBDIR= \
caesar \
factor \
fortune \
grdc \
morse \
number \
pom \
primes \
random \
${_tests}
.if ${MK_TESTS} != "no"
_tests= tests
.endif
.include <bsd.subdir.mk>

View File

@ -1,6 +0,0 @@
# @(#)Makefile.inc 8.1 (Berkeley) 5/31/93
# $FreeBSD$
BINDIR?= /usr/bin
FILESDIR?= ${SHAREDIR}/games
WARNS?= 6

View File

@ -1,10 +0,0 @@
# $FreeBSD$
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/games
.PATH: ${.CURDIR:H:H}/tests
KYUAFILE= yes
.include <bsd.test.mk>

View File

@ -166,7 +166,7 @@ compat:
-f ${.CURDIR}/../etc/mtree/BSD.include.dist \
-p ${DESTDIR}${INCLUDEDIR} > /dev/null
.if ${MK_META_MODE} == "yes"
touch ${.TARGET}
@touch ${.TARGET}
.endif
copies:
@ -255,8 +255,7 @@ copies:
${INSTALL} -C -o ${BINOWN} -g ${BINGRP} -m 444 teken.h \
${DESTDIR}${INCLUDEDIR}/teken
.if ${MK_META_MODE} == "yes"
cd ${.OBJDIR}
touch ${.TARGET}
@touch ${.OBJDIR}/${.TARGET}
.endif
symlinks:
@ -373,8 +372,7 @@ symlinks:
${DESTDIR}${INCLUDEDIR}/rpc; \
done
.if ${MK_META_MODE} == "yes"
cd ${.OBJDIR}
touch ${.TARGET}
@touch ${.OBJDIR}/${.TARGET}
.endif
.if ${MACHINE} == "host"

View File

@ -168,12 +168,6 @@ struct explore {
};
static const struct explore explore[] = {
{ PF_LOCAL, SOCK_DGRAM, ANY,
AF_ANY | PROTOCOL_ANY },
{ PF_LOCAL, SOCK_STREAM, ANY,
AF_ANY | PROTOCOL_ANY },
{ PF_LOCAL, SOCK_SEQPACKET, ANY,
AF_ANY | PROTOCOL_ANY },
#ifdef INET6
{ PF_INET6, SOCK_DGRAM, IPPROTO_UDP,
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
@ -200,6 +194,12 @@ static const struct explore explore[] = {
AF_ANY | SOCKTYPE_ANY },
{ PF_INET, SOCK_RAW, ANY,
AF_ANY | PROTOCOL_ANY },
{ PF_LOCAL, SOCK_DGRAM, ANY,
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
{ PF_LOCAL, SOCK_STREAM, ANY,
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
{ PF_LOCAL, SOCK_SEQPACKET, ANY,
AF_ANY | SOCKTYPE_ANY | PROTOCOL_ANY },
{ -1, 0, 0, 0 },
};
@ -1245,7 +1245,9 @@ explore_numeric(const struct addrinfo *pai, const char *hostname,
if (pai->ai_family == afd->a_af) {
GET_AI(ai, afd, p);
GET_PORT(ai, servname);
if ((pai->ai_flags & AI_CANONNAME)) {
if ((pai->ai_family == AF_INET ||
pai->ai_family == AF_INET6) &&
(pai->ai_flags & AI_CANONNAME)) {
/*
* Set the numeric address itself as the canonical
* name, based on a clarification in RFC3493.

View File

@ -28,7 +28,7 @@
.\" @(#)madvise.2 8.1 (Berkeley) 6/9/93
.\" $FreeBSD$
.\"
.Dd January 30, 2014
.Dd October 3, 2015
.Dt POSIX_FADVISE 2
.Os
.Sh NAME
@ -89,11 +89,13 @@ read or written.
Future access to this data may require a read operation.
.El
.Sh RETURN VALUES
.Rv -std posix_fadvise
.Sh ERRORS
The
If successful,
.Fn posix_fadvise
system call returns zero on success, and an error on failure:
returns zero.
It returns an error on failure, without setting
.Va errno .
.Sh ERRORS
Possible failure conditions:
.Bl -tag -width Er
.It Bq Er EBADF
The

View File

@ -20,6 +20,8 @@
#ifndef OHASH_H
#define OHASH_H
#include <stddef.h>
/* Open hashing support.
* Open hashing was chosen because it is much lighter than other hash
* techniques, and more efficient in most cases.

View File

@ -35,10 +35,10 @@ SRCS+= libusb10_io.c
.if defined(COMPAT_32BIT)
CFLAGS+= -DCOMPAT_32BIT
.else
.endif
FILES= libusb-0.1.pc libusb-1.0.pc libusb-2.0.pc
FILESDIR= ${LIBDATADIR}/pkgconfig
.endif
#
# Cross platform support

View File

@ -68,10 +68,8 @@ test: example minigzip
(export LD_LIBRARY_PATH=. ; \
echo hello world | ./minigzip | ./minigzip -d )
.ifndef COMPAT_32BIT
FILES= zlib.pc
FILESDIR= ${LIBDATADIR}/pkgconfig
.endif
.include <bsd.lib.mk>

View File

@ -22,10 +22,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
of=/dev/${mddev} bs=1k seek=8
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}

View File

@ -21,10 +21,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
of=/dev/${mddev} bs=1k seek=8
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}

View File

@ -22,10 +22,8 @@ arm_install_uboot() {
UBOOT_FILES="u-boot.img"
FATMOUNT="${DESTDIR%${KERNEL}}/fat"
UFSMOUNT="${DESTDIR%${KERNEL}}/ufs"
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/sunxi-spl.bin \
of=/dev/${mddev} bs=1k seek=8
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/${UBOOT_FILES} \
of=/dev/${mddev} bs=1k seek=40 conv=notrunc,sync
chroot ${CHROOTDIR} dd if=${UBOOT_DIR}/u-boot-sunxi-with-spl.bin \
of=/dev/${mddev} bs=1k seek=8 conv=sync
chroot ${CHROOTDIR} mkdir -p "${FATMOUNT}" "${UFSMOUNT}"
chroot ${CHROOTDIR} mount_msdosfs /dev/${mddev}s1 ${FATMOUNT}
chroot ${CHROOTDIR} mount /dev/${mddev}s2a ${UFSMOUNT}

View File

@ -32,15 +32,19 @@ CLEANFILES+= ipnat.tab.c ipnat.tab.h
CLEANFILES+= ippool_y.c ippool_l.c
CLEANFILES+= ippool.tab.c ippool.tab.h
ipnat_y.c: ipnat_y.y
ipnat.tab.c ipnat.tab.h: ipnat_y.y
${YACC} -b ipnat -d ${.ALLSRC}
ipnat_y.c: ipnat.tab.c
sed -e 's/yy/ipnat_yy/g' \
-e 's/y.tab.c/ipnat_y.c/' \
-e s/\"ipnat_y.y\"/\"..\\/tools\\/ipnat_y.y\"/ \
ipnat.tab.c > ${.TARGET}
ipnat_y.h: ipnat.tab.h
sed -e 's/yy/ipnat_yy/g' \
-e 's/y.tab.h/ipnat_y.h/' \
ipnat.tab.h > ${.TARGET:.c=.h}
ipnat.tab.h > ${.TARGET}
ipnat_y.h: ipnat_y.c
@ -54,13 +58,17 @@ ipnat_l.h: lexer.h
sed -e 's/yy/ipnat_yy/g' \
${.ALLSRC} > ${.TARGET}
ippool_y.c: ippool_y.y
ippool.tab.c ippool.tab.h: ippool_y.y
${YACC} -b ippool -d ${.ALLSRC}
ippool_y.c: ippool.tab.c
sed -e 's/yy/ippool_yy/g' \
-e 's/"ippool_y.y"/"..\/tools\/ippool_y.y"/' \
ippool.tab.c > ${.TARGET}
ippool_y.h: ippool.tab.h
sed -e 's/yy/ippool_yy/g' \
ippool.tab.h > ${.TARGET:.c=.h}
ippool.tab.h > ${.TARGET}
ippool_y.h: ippool_y.c
@ -74,13 +82,17 @@ ippool_l.h: lexer.h
sed -e 's/yy/ippool_yy/g' \
${.ALLSRC} > ${.TARGET}
ipf_y.c: ipf_y.y
ipf.tab.c ipf.tab.h: ipf_y.y
${YACC} -b ipf -d ${.ALLSRC}
ipf_y.c: ipf.tab.c
sed -e 's/yy/ipf_yy/g' \
-e 's/"ipf_y.y"/"..\/tools\/ipf_y.y"/' \
ipf.tab.c > ${.TARGET}
ipf_y.h: ipf.tab.h
sed -e 's/yy/ipf_yy/g' \
ipf.tab.h > ${.TARGET:.c=.h}
ipf.tab.h > ${.TARGET}
ipf_y.h: ipf_y.c

View File

@ -3625,7 +3625,7 @@ compile_rule(char *av[], uint32_t *rbuf, int *rbufsize, struct tidx *tstate)
action->opcode = O_NAT;
action->len = F_INSN_SIZE(ipfw_insn_nat);
CHECK_ACTLEN;
if (_substrcmp(*av, "global") == 0) {
if (*av != NULL && _substrcmp(*av, "global") == 0) {
action->arg1 = 0;
av++;
break;

View File

@ -12,7 +12,8 @@ SUBDIR= ${_toolkit}
_toolkit= toolkit
.endif
SCRIPTS= disklatency \
SCRIPTS= blocking \
disklatency \
disklatencycmd \
hotopen \
nfsattrstats \

57
share/dtrace/blocking Executable file
View File

@ -0,0 +1,57 @@
#!/usr/sbin/dtrace -s
/*-
* Copyright (c) 2015 Pawel Jakub Dawidek <pawel@dawidek.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*
* This little script is for use with programs that use event loop and should
* sleep only when waiting for events (eg. via kevent(2)). When a program is
* going to sleep in the kernel, the script will show its name, PID, kernel
* stack trace and userland stack trace. Sleeping in kevent(2) is ignored.
*
* usage: blocking <execname>
*/
#pragma D option quiet
syscall::kevent:entry
/execname == $$1/
{
self->inkevent = 1;
}
fbt::sleepq_add:entry
/!self->inkevent && execname == $$1/
{
printf("\n%s(%d) is blocking...\n", execname, pid);
stack();
ustack();
}
syscall::kevent:return
/execname == $$1/
{
self->inkevent = 0;
}

View File

@ -28,7 +28,7 @@
.\" @(#)hier.7 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
.Dd January 14, 2015
.Dd October 2, 2015
.Dt HIER 7
.Os
.Sh NAME
@ -685,9 +685,6 @@ source code for contributed cryptography software
.It Pa etc/
source code for files in
.Pa /etc
.It Pa games/
source code for files in
.Pa /usr/games
.It Pa gnu/
Utilities covered by the GNU General Public License
.It Pa include/

View File

@ -149,7 +149,7 @@ CXXFLAGS.clang+= -Wno-c++11-extensions
.if ${MK_SSP} != "no" && \
${MACHINE_CPUARCH} != "arm" && ${MACHINE_CPUARCH} != "mips"
# Don't use -Wstack-protector as it breaks world with -Werror.
SSP_CFLAGS?= -fstack-protector
SSP_CFLAGS?= -fstack-protector-strong
CFLAGS+= ${SSP_CFLAGS}
.endif # SSP && !ARM && !MIPS

View File

@ -237,10 +237,11 @@ stage_as.$s: .dirdep
CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes
# stage_*links usually needs to follow any others.
.for t in ${STAGE_TARGETS:N*links:O:u}
.ORDER: $t stage_links
.ORDER: $t stage_symlinks
.if !empty(STAGE_SETS) && !empty(STAGE_TARGETS:Nstage_links)
.for s in ${STAGE_SETS:O:u}
stage_links.$s: ${STAGE_TARGETS:Nstage_links:O:u}
.endfor
.endif
# make sure this exists
staging:

View File

@ -75,7 +75,7 @@ __FBSDID("$FreeBSD$");
#endif /* ! COPY_CHUNK */
#ifndef SAVE_REGS
#define SAVE_REGS stmfd sp!, {r4-r8, lr}
#define SAVE_REGS stmfd sp!, {r4-r8, lr}; _SAVE({r4-r8, lr})
#define RESTORE_REGS ldmfd sp!, {r4-r8, pc}
#endif
@ -134,6 +134,7 @@ END(bcopy_page)
ENTRY(bzero_page)
stmfd sp!, {r4-r8, lr}
_SAVE({r4-r8, lr})
#ifdef BIG_LOOPS
mov r2, #(PAGE_SIZE >> 9)
#else
@ -189,6 +190,7 @@ END(bzero_page)
ENTRY(bcopy_page)
pld [r0]
stmfd sp!, {r4, r5}
_SAVE({r4, r5})
mov ip, #32
ldr r2, [r0], #0x04 /* 0x00 */
ldr r3, [r0], #0x04 /* 0x04 */

View File

@ -68,7 +68,7 @@ __FBSDID("$FreeBSD$");
#endif
#define SAVE_REGS stmfd sp!, {r4-r11}
#define SAVE_REGS stmfd sp!, {r4-r11}; _SAVE({r4-r11})
#define RESTORE_REGS ldmfd sp!, {r4-r11}
#if defined(_ARM_ARCH_5E)
@ -341,6 +341,7 @@ ENTRY(copyout)
cmp r2, r3
blt .Lnormale
stmfd sp!, {r0-r2, r4, lr}
_SAVE({r0-r2, r4, lr})
mov r3, r0
mov r0, r1
mov r1, r3

View File

@ -1069,7 +1069,7 @@ init_proc0(vm_offset_t kstack)
(thread0.td_kstack + kstack_pages * PAGE_SIZE) - 1;
thread0.td_pcb->pcb_flags = 0;
thread0.td_pcb->pcb_vfpcpu = -1;
thread0.td_pcb->pcb_vfpstate.fpscr = VFPSCR_DN | VFPSCR_FZ;
thread0.td_pcb->pcb_vfpstate.fpscr = VFPSCR_DN;
thread0.td_frame = &proc0_tf;
pcpup->pc_curpcb = thread0.td_pcb;
}

View File

@ -134,7 +134,7 @@ cpu_fork(register struct thread *td1, register struct proc *p2,
pcb2->pcb_regs.sf_sp = STACKALIGN(td2->td_frame);
pcb2->pcb_vfpcpu = -1;
pcb2->pcb_vfpstate.fpscr = VFPSCR_DN | VFPSCR_FZ;
pcb2->pcb_vfpstate.fpscr = VFPSCR_DN;
tf = td2->td_frame;
tf->tf_spsr &= ~PSR_C;

View File

@ -53,10 +53,12 @@
#define STOP_UNWINDING .cantunwind
#define _FNSTART .fnstart
#define _FNEND .fnend
#define _SAVE(...) .save __VA_ARGS__
#else
#define STOP_UNWINDING
#define _FNSTART
#define _FNEND
#define _SAVE(...)
#endif
/*

View File

@ -439,4 +439,37 @@ atomic_subtract_long(volatile u_long *p, u_long v)
atomic_subtract_32((volatile uint32_t *)p, v);
}
/*
* ARMv5 does not support SMP. For both kernel and user modes, only a
* compiler barrier is needed for fences, since CPU is always
* self-consistent.
*/
static __inline void
atomic_thread_fence_acq(void)
{
__compiler_membar();
}
static __inline void
atomic_thread_fence_rel(void)
{
__compiler_membar();
}
static __inline void
atomic_thread_fence_acq_rel(void)
{
__compiler_membar();
}
static __inline void
atomic_thread_fence_seq_cst(void)
{
__compiler_membar();
}
#endif /* _MACHINE_ATOMIC_H_ */

View File

@ -596,4 +596,32 @@ atomic_store_rel_long(volatile u_long *p, u_long v)
#undef ATOMIC_ACQ_REL
#undef ATOMIC_ACQ_REL_LONG
static __inline void
atomic_thread_fence_acq(void)
{
dmb();
}
static __inline void
atomic_thread_fence_rel(void)
{
dmb();
}
static __inline void
atomic_thread_fence_acq_rel(void)
{
dmb();
}
static __inline void
atomic_thread_fence_seq_cst(void)
{
dmb();
}
#endif /* _MACHINE_ATOMIC_V6_H_ */

View File

@ -82,34 +82,6 @@ atomic_store_long(volatile u_long *dst, u_long src)
*dst = src;
}
static __inline void
atomic_thread_fence_acq(void)
{
dmb();
}
static __inline void
atomic_thread_fence_rel(void)
{
dmb();
}
static __inline void
atomic_thread_fence_acq_rel(void)
{
dmb();
}
static __inline void
atomic_thread_fence_seq_cst(void)
{
dmb();
}
#define atomic_clear_ptr atomic_clear_32
#define atomic_set_ptr atomic_set_32
#define atomic_cmpset_ptr atomic_cmpset_32

View File

@ -156,7 +156,8 @@ static driver_t ti_aintc_driver = {
static devclass_t ti_aintc_devclass;
DRIVER_MODULE(aintc, simplebus, ti_aintc_driver, ti_aintc_devclass, 0, 0);
EARLY_DRIVER_MODULE(aintc, simplebus, ti_aintc_driver, ti_aintc_devclass,
0, 0, BUS_PASS_INTERRUPT + BUS_PASS_ORDER_MIDDLE);
int
arm_get_next_irq(int last_irq)

View File

@ -275,7 +275,7 @@ do_el1h_sync(struct trapframe *frame)
*/
KASSERT((esr & ESR_ELx_IL) == ESR_ELx_IL ||
(exception == EXCP_DATA_ABORT && ((esr & ISS_DATA_ISV) == 0)),
("Invalid instruction length in exception"));
("Invalid instruction length in exception, esr %lx", esr));
CTR4(KTR_TRAP,
"do_el1_sync: curthread: %p, esr %lx, elr: %lx, frame: %p",
@ -377,6 +377,11 @@ do_el0_sync(struct trapframe *frame)
case EXCP_UNKNOWN:
el0_excp_unknown(frame);
break;
case EXCP_PC_ALIGN:
td = curthread;
call_trapsignal(td, SIGBUS, BUS_ADRALN, (void *)frame->tf_elr);
userret(td, frame);
break;
case EXCP_BRK:
td = curthread;
call_trapsignal(td, SIGTRAP, TRAP_BRKPT, (void *)frame->tf_elr);

View File

@ -1128,7 +1128,7 @@ static int
tpc_process_wut(struct tpc_list *list)
{
struct tpc_io *tio, *tior, *tiow;
struct runl run, *prun;
struct runl run;
int drange, srange;
off_t doffset, soffset;
off_t srclba, dstlba, numbytes, donebytes, roundbytes;
@ -1208,8 +1208,7 @@ tpc_process_wut(struct tpc_list *list)
// srclba, dstlba);
donebytes = 0;
TAILQ_INIT(&run);
prun = &run;
list->tbdio = 1;
list->tbdio = 0;
TAILQ_INIT(&list->allio);
while (donebytes < numbytes) {
roundbytes = numbytes - donebytes;
@ -1262,8 +1261,8 @@ tpc_process_wut(struct tpc_list *list)
tiow->io->io_hdr.ctl_private[CTL_PRIV_FRONTEND].ptr = tiow;
TAILQ_INSERT_TAIL(&tior->run, tiow, rlinks);
TAILQ_INSERT_TAIL(prun, tior, rlinks);
prun = &tior->run;
TAILQ_INSERT_TAIL(&run, tior, rlinks);
list->tbdio++;
donebytes += roundbytes;
srclba += roundbytes / srcblock;
dstlba += roundbytes / dstblock;

View File

@ -449,7 +449,7 @@ dmu_buf_hold_array_by_dnode(dnode_t *dn, uint64_t offset, uint64_t length,
}
if ((flags & DMU_READ_NO_PREFETCH) == 0 && read &&
length < zfetch_array_rd_sz) {
length <= zfetch_array_rd_sz) {
dmu_zfetch(&dn->dn_zfetch, blkid, nblks);
}
rw_exit(&dn->dn_struct_rwlock);

View File

@ -1438,8 +1438,7 @@ ath_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
int needbeacon, error;
enum ieee80211_opmode ic_opmode;
avp = (struct ath_vap *) malloc(sizeof(struct ath_vap),
M_80211_VAP, M_WAITOK | M_ZERO);
avp = malloc(sizeof(struct ath_vap), M_80211_VAP, M_WAITOK | M_ZERO);
needbeacon = 0;
IEEE80211_ADDR_COPY(mac, mac0);

View File

@ -199,7 +199,7 @@ ath_beacon_alloc(struct ath_softc *sc, struct ieee80211_node *ni)
* we assume the mbuf routines will return us something
* with this alignment (perhaps should assert).
*/
m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off);
m = ieee80211_beacon_alloc(ni);
if (m == NULL) {
device_printf(sc->sc_dev, "%s: cannot get mbuf\n", __func__);
sc->sc_stats.ast_be_nombuf++;
@ -713,7 +713,7 @@ ath_beacon_generate(struct ath_softc *sc, struct ieee80211vap *vap)
/* XXX lock mcastq? */
nmcastq = avp->av_mcastq.axq_depth;
if (ieee80211_beacon_update(bf->bf_node, &vap->iv_bcn_off, m, nmcastq)) {
if (ieee80211_beacon_update(bf->bf_node, m, nmcastq)) {
/* XXX too conservative? */
bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m,
@ -829,7 +829,7 @@ ath_beacon_start_adhoc(struct ath_softc *sc, struct ieee80211vap *vap)
*/
bf = avp->av_bcbuf;
m = bf->bf_m;
if (ieee80211_beacon_update(bf->bf_node, &vap->iv_bcn_off, m, 0)) {
if (ieee80211_beacon_update(bf->bf_node, m, 0)) {
/* XXX too conservative? */
bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap);
error = bus_dmamap_load_mbuf_sg(sc->sc_dmat, bf->bf_dmamap, m,

View File

@ -527,8 +527,7 @@ ath_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
* slot(s) must already have been allocated by ath_key_alloc.
*/
int
ath_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k,
const u_int8_t mac[IEEE80211_ADDR_LEN])
ath_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
struct ath_softc *sc = vap->iv_ic->ic_softc;

View File

@ -35,8 +35,7 @@
extern int ath_key_alloc(struct ieee80211vap *, struct ieee80211_key *,
ieee80211_keyix *, ieee80211_keyix *);
extern int ath_key_delete(struct ieee80211vap *, const struct ieee80211_key *);
extern int ath_key_set(struct ieee80211vap *, const struct ieee80211_key *,
const u_int8_t mac[IEEE80211_ADDR_LEN]);
extern int ath_key_set(struct ieee80211vap *, const struct ieee80211_key *);
extern int ath_keyset(struct ath_softc *sc, struct ieee80211vap *vap,
const struct ieee80211_key *k, struct ieee80211_node *bss);

View File

@ -1782,12 +1782,6 @@ void drm_driver_irq_preinstall(struct drm_device *dev);
void drm_driver_irq_postinstall(struct drm_device *dev);
void drm_driver_irq_uninstall(struct drm_device *dev);
/* AGP/PCI Express/GART support (drm_agpsupport.c) */
void *drm_agp_allocate_memory(size_t pages, u32 type);
int drm_agp_free_memory(void *handle);
int drm_agp_bind_memory(void *handle, off_t start);
int drm_agp_unbind_memory(void *handle);
/* sysctl support (drm_sysctl.h) */
extern int drm_sysctl_init(struct drm_device *dev);
extern int drm_sysctl_cleanup(struct drm_device *dev);

View File

@ -663,7 +663,7 @@ int drm_plane_init(struct drm_device *dev, struct drm_plane *plane,
plane->dev = dev;
plane->funcs = funcs;
plane->format_types = malloc(sizeof(uint32_t) * format_count,
DRM_MEM_KMS, M_WAITOK);
DRM_MEM_KMS, M_NOWAIT);
if (!plane->format_types) {
DRM_DEBUG_KMS("out of memory when allocating plane\n");
drm_mode_object_put(dev, &plane->base);
@ -1010,7 +1010,7 @@ int drm_mode_group_init(struct drm_device *dev, struct drm_mode_group *group)
total_objects += dev->mode_config.num_encoder;
group->id_list = malloc(total_objects * sizeof(uint32_t),
DRM_MEM_KMS, M_WAITOK | M_ZERO);
DRM_MEM_KMS, M_NOWAIT | M_ZERO);
if (!group->id_list)
return -ENOMEM;
@ -1998,7 +1998,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
connector_set = malloc(crtc_req->count_connectors *
sizeof(struct drm_connector *),
DRM_MEM_KMS, M_WAITOK);
DRM_MEM_KMS, M_NOWAIT);
if (!connector_set) {
ret = -ENOMEM;
goto out;
@ -2523,7 +2523,7 @@ int drm_mode_dirtyfb_ioctl(struct drm_device *dev,
goto out_err1;
}
clips = malloc(num_clips * sizeof(*clips), DRM_MEM_KMS,
M_WAITOK | M_ZERO);
M_NOWAIT | M_ZERO);
if (!clips) {
ret = -ENOMEM;
goto out_err1;
@ -2774,13 +2774,13 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
int ret;
property = malloc(sizeof(struct drm_property), DRM_MEM_KMS,
M_WAITOK | M_ZERO);
M_NOWAIT | M_ZERO);
if (!property)
return NULL;
if (num_values) {
property->values = malloc(sizeof(uint64_t)*num_values, DRM_MEM_KMS,
M_WAITOK | M_ZERO);
M_NOWAIT | M_ZERO);
if (!property->values)
goto fail;
}
@ -2908,7 +2908,7 @@ int drm_property_add_enum(struct drm_property *property, int index,
}
prop_enum = malloc(sizeof(struct drm_property_enum), DRM_MEM_KMS,
M_WAITOK | M_ZERO);
M_NOWAIT | M_ZERO);
if (!prop_enum)
return -ENOMEM;
@ -3104,7 +3104,7 @@ static struct drm_property_blob *drm_property_create_blob(struct drm_device *dev
return NULL;
blob = malloc(sizeof(struct drm_property_blob)+length, DRM_MEM_KMS,
M_WAITOK | M_ZERO);
M_NOWAIT | M_ZERO);
if (!blob)
return NULL;
@ -3434,7 +3434,7 @@ int drm_mode_crtc_set_gamma_size(struct drm_crtc *crtc,
crtc->gamma_size = gamma_size;
crtc->gamma_store = malloc(gamma_size * sizeof(uint16_t) * 3,
DRM_MEM_KMS, M_WAITOK | M_ZERO);
DRM_MEM_KMS, M_NOWAIT | M_ZERO);
if (!crtc->gamma_store) {
crtc->gamma_size = 0;
return -ENOMEM;
@ -3632,7 +3632,7 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
file_priv->event_space -= sizeof e->event;
mtx_unlock(&dev->event_lock);
e = malloc(sizeof *e, DRM_MEM_KMS, M_WAITOK | M_ZERO);
e = malloc(sizeof *e, DRM_MEM_KMS, M_NOWAIT | M_ZERO);
if (e == NULL) {
mtx_lock(&dev->event_lock);
file_priv->event_space += sizeof e->event;

View File

@ -136,7 +136,7 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
sx_xlock(&drm_global_mutex);
/*
* FIXME Linux<->FreeBSD: On Linux, counter updated outisde
* FIXME Linux<->FreeBSD: On Linux, counter updated outside
* global mutex.
*/
if (!dev->open_count++)

View File

@ -225,7 +225,7 @@ int drm_pci_set_unique(struct drm_device *dev,
master->unique_len = u->unique_len;
master->unique_size = u->unique_len + 1;
master->unique = malloc(master->unique_size, DRM_MEM_DRIVER, M_WAITOK);
master->unique = malloc(master->unique_size, DRM_MEM_DRIVER, M_NOWAIT);
if (!master->unique) {
ret = -ENOMEM;
goto err;

View File

@ -94,9 +94,9 @@ static int drm_minor_get_id(struct drm_device *dev, int type)
if (type == DRM_MINOR_CONTROL) {
new_id += 64;
} else if (type == DRM_MINOR_RENDER) {
new_id += 128;
}
} else if (type == DRM_MINOR_RENDER) {
new_id += 128;
}
return new_id;
}

View File

@ -1452,6 +1452,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags)
}
}
pci_enable_busmaster(dev->dev);
intel_opregion_init(dev);
callout_init(&dev_priv->hangcheck_timer, 1);

View File

@ -894,6 +894,7 @@ int intel_gpu_reset(struct drm_device *dev)
case 4:
ret = i965_do_reset(dev);
break;
case 3:
case 2:
ret = i8xx_do_reset(dev);
break;

View File

@ -533,11 +533,9 @@ void intel_opregion_fini(struct drm_device *dev)
opregion->vbt = NULL;
}
#else
int
void
intel_opregion_init(struct drm_device *dev)
{
return (0);
}
void

View File

@ -194,7 +194,7 @@ static void ndis_media_status (struct ifnet *, struct ifmediareq *);
static int ndis_set_cipher (struct ndis_softc *, int);
static int ndis_set_wpa (struct ndis_softc *, void *, int);
static int ndis_add_key (struct ieee80211vap *,
const struct ieee80211_key *, const u_int8_t []);
const struct ieee80211_key *);
static int ndis_del_key (struct ieee80211vap *,
const struct ieee80211_key *);
static void ndis_setmulti (struct ndis_softc *);
@ -3070,8 +3070,7 @@ ndis_del_key(struct ieee80211vap *vap, const struct ieee80211_key *key)
* set after initial authentication with the AP.
*/
static int
ndis_add_key(struct ieee80211vap *vap, const struct ieee80211_key *key,
const uint8_t mac[IEEE80211_ADDR_LEN])
ndis_add_key(struct ieee80211vap *vap, const struct ieee80211_key *key)
{
struct ndis_softc *sc = vap->iv_ic->ic_softc;
ndis_80211_key rkey;

View File

@ -111,7 +111,10 @@ static int mwl_key_alloc(struct ieee80211vap *,
ieee80211_keyix *, ieee80211_keyix *);
static int mwl_key_delete(struct ieee80211vap *,
const struct ieee80211_key *);
static int mwl_key_set(struct ieee80211vap *, const struct ieee80211_key *,
static int mwl_key_set(struct ieee80211vap *,
const struct ieee80211_key *);
static int _mwl_key_set(struct ieee80211vap *,
const struct ieee80211_key *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
static int mwl_mode_init(struct mwl_softc *);
static void mwl_update_mcast(struct ieee80211com *);
@ -1604,7 +1607,13 @@ addgroupflags(MWL_HAL_KEYVAL *hk, const struct ieee80211_key *k)
* slot(s) must already have been allocated by mwl_key_alloc.
*/
static int
mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k,
mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
return (_mwl_key_set(vap, k, k->wk_macaddr));
}
static int
_mwl_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k,
const uint8_t mac[IEEE80211_ADDR_LEN])
{
#define GRPXMIT (IEEE80211_KEY_XMIT | IEEE80211_KEY_GROUP)
@ -1834,10 +1843,9 @@ mwl_beacon_setup(struct ieee80211vap *vap)
{
struct mwl_hal_vap *hvap = MWL_VAP(vap)->mv_hvap;
struct ieee80211_node *ni = vap->iv_bss;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct mbuf *m;
m = ieee80211_beacon_alloc(ni, bo);
m = ieee80211_beacon_alloc(ni);
if (m == NULL)
return ENOBUFS;
mwl_hal_setbeacon(hvap, mtod(m, const void *), m->m_len);
@ -3911,7 +3919,8 @@ mwl_setanywepkey(struct ieee80211vap *vap, const uint8_t mac[IEEE80211_ADDR_LEN]
IEEE80211_F_PRIVACY &&
vap->iv_def_txkey != IEEE80211_KEYIX_NONE &&
vap->iv_nw_keys[vap->iv_def_txkey].wk_keyix != IEEE80211_KEYIX_NONE)
(void) mwl_key_set(vap, &vap->iv_nw_keys[vap->iv_def_txkey], mac);
(void) _mwl_key_set(vap, &vap->iv_nw_keys[vap->iv_def_txkey],
mac);
}
static int
@ -3956,7 +3965,7 @@ mwl_setglobalkeys(struct ieee80211vap *vap)
wk = &vap->iv_nw_keys[0];
for (; wk < &vap->iv_nw_keys[IEEE80211_WEP_NKID]; wk++)
if (wk->wk_keyix != IEEE80211_KEYIX_NONE)
(void) mwl_key_set(vap, wk, vap->iv_myaddr);
(void) _mwl_key_set(vap, wk, vap->iv_myaddr);
}
/*

View File

@ -768,7 +768,7 @@ rt2560_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
vap->iv_opmode == IEEE80211_M_IBSS ||
vap->iv_opmode == IEEE80211_M_MBSS) {
m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off);
m = ieee80211_beacon_alloc(ni);
if (m == NULL) {
device_printf(sc->sc_dev,
"could not allocate beacon\n");
@ -1286,7 +1286,6 @@ static void
rt2560_beacon_expire(struct rt2560_softc *sc)
{
struct ieee80211com *ic = &sc->sc_ic;
struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
struct rt2560_tx_data *data;
if (ic->ic_opmode != IEEE80211_M_IBSS &&
@ -1305,7 +1304,7 @@ rt2560_beacon_expire(struct rt2560_softc *sc)
bus_dmamap_unload(sc->bcnq.data_dmat, data->map);
/* XXX 1 =>'s mcast frames which means all PS sta's will wakeup! */
ieee80211_beacon_update(data->ni, &vap->iv_bcn_off, data->m, 1);
ieee80211_beacon_update(data->ni, data->m, 1);
rt2560_tx_bcn(sc, data->m, data->ni);

View File

@ -2626,13 +2626,11 @@ static int
rt2661_prepare_beacon(struct rt2661_softc *sc, struct ieee80211vap *vap)
{
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct rt2661_tx_desc desc;
struct mbuf *m0;
int rate;
m0 = ieee80211_beacon_alloc(vap->iv_bss, bo);
if (m0 == NULL) {
if ((m0 = ieee80211_beacon_alloc(vap->iv_bss))== NULL) {
device_printf(sc->sc_dev, "could not allocate beacon frame\n");
return ENOBUFS;
}

View File

@ -4268,12 +4268,11 @@ static int
rt2860_setup_beacon(struct rt2860_softc *sc, struct ieee80211vap *vap)
{
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct rt2860_txwi txwi;
struct mbuf *m;
int ridx;
if ((m = ieee80211_beacon_alloc(vap->iv_bss, bo)) == NULL)
if ((m = ieee80211_beacon_alloc(vap->iv_bss)) == NULL)
return ENOBUFS;
memset(&txwi, 0, sizeof txwi);

View File

@ -211,7 +211,16 @@ random_sources_feed(void)
LIST_FOREACH(rrs, &source_list, rrs_entries) {
for (i = 0; i < p_random_alg_context->ra_poolcount*(local_read_rate + 1); i++) {
n = rrs->rrs_source->rs_read(entropy, sizeof(entropy));
KASSERT((n > 0 && n <= sizeof(entropy)), ("very bad return from rs_read (= %d) in %s", n, __func__));
KASSERT((n <= sizeof(entropy)), ("%s: rs_read returned too much data (%u > %zu)", __func__, n, sizeof(entropy)));
/* It would appear that in some circumstances (e.g. virtualisation),
* the underlying hardware entropy source might not always return
* random numbers. Accept this but make a noise. If too much happens,
* can that source be trusted?
*/
if (n == 0) {
printf("%s: rs_read for hardware device '%s' returned no entropy.\n", __func__, rrs->rrs_source->rs_ident);
continue;
}
random_harvest_direct(entropy, n, (n*8)/2, rrs->rrs_source->rs_source);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -34,13 +34,36 @@
#define RT2573_WRITE_LED 0x0a
/*
* Control and status registers.
* WME registers.
*/
#define RT2573_AIFSN_CSR 0x0400
#define RT2573_CWMIN_CSR 0x0404
#define RT2573_CWMAX_CSR 0x0408
#define RT2573_TXOP01_CSR 0x040C
#define RT2573_TXOP23_CSR 0x0410
#define RT2573_MCU_CODE_BASE 0x0800
#define RT2573_HW_BEACON_BASE0 0x2400
/*
* H/w encryption/decryption support
*/
#define KEY_SIZE (IEEE80211_KEYBUF_SIZE + IEEE80211_MICBUF_SIZE)
#define RT2573_ADDR_MAX 64
#define RT2573_SKEY_MAX 4
#define RT2573_SKEY(vap, kidx) (0x1000 + ((vap) * RT2573_SKEY_MAX + \
(kidx)) * KEY_SIZE)
#define RT2573_PKEY(id) (0x1200 + (id) * KEY_SIZE)
#define RT2573_ADDR_ENTRY(id) (0x1a00 + (id) * 8)
/*
* Shared memory area
*/
#define RT2573_HW_BCN_BASE(id) (0x2400 + (id) * 0x100)
/*
* Control and status registers.
*/
#define RT2573_MAC_CSR0 0x3000
#define RT2573_MAC_CSR1 0x3004
#define RT2573_MAC_CSR2 0x3008
@ -95,13 +118,23 @@
#define RT2573_STA_CSR5 0x30d4
/* possible values for register RT2573_ADDR_MODE */
#define RT2573_MODE_MASK 0x7
#define RT2573_MODE_NOSEC 0
#define RT2573_MODE_WEP40 1
#define RT2573_MODE_WEP104 2
#define RT2573_MODE_TKIP 3
#define RT2573_MODE_AES_CCMP 4
#define RT2573_MODE_CKIP40 5
#define RT2573_MODE_CKIP104 6
/* possible flags for register RT2573_MAC_CSR1 */
#define RT2573_RESET_ASIC (1 << 0)
#define RT2573_RESET_BBP (1 << 1)
#define RT2573_HOST_READY (1 << 2)
/* possible flags for register MAC_CSR5 */
#define RT2573_ONE_BSSID 3
#define RT2573_NUM_BSSID_MSK(n) (((n * 3) & 3) << 16)
/* possible flags for register TXRX_CSR0 */
/* Tx filter flags are in the low 16 bits */
@ -122,13 +155,20 @@
#define RT2573_SHORT_PREAMBLE (1 << 18)
#define RT2573_MRR_ENABLED (1 << 19)
#define RT2573_MRR_CCK_FALLBACK (1 << 22)
#define RT2573_LONG_RETRY(max) ((max) << 24)
#define RT2573_LONG_RETRY_MASK (0xf << 24)
#define RT2573_SHORT_RETRY(max) ((max) << 28)
#define RT2573_SHORT_RETRY_MASK (0xf << 28)
/* possible flags for register TXRX_CSR9 */
#define RT2573_TSF_TICKING (1 << 16)
#define RT2573_TSF_MODE(x) (((x) & 0x3) << 17)
/* TBTT stands for Target Beacon Transmission Time */
#define RT2573_ENABLE_TBTT (1 << 19)
#define RT2573_GENERATE_BEACON (1 << 20)
#define RT2573_TSF_TIMER_EN (1 << 16)
#define RT2573_TSF_SYNC_MODE(x) (((x) & 0x3) << 17)
#define RT2573_TSF_SYNC_MODE_DIS 0
#define RT2573_TSF_SYNC_MODE_STA 1
#define RT2573_TSF_SYNC_MODE_IBSS 2
#define RT2573_TSF_SYNC_MODE_HOSTAP 3
#define RT2573_TBTT_TIMER_EN (1 << 19)
#define RT2573_BCN_TX_EN (1 << 20)
/* possible flags for register PHY_CSR0 */
#define RT2573_PA_PE_2GHZ (1 << 16)
@ -175,6 +215,10 @@ struct rum_tx_desc {
#define RT2573_TX_OFDM (1 << 5)
#define RT2573_TX_IFS_SIFS (1 << 6)
#define RT2573_TX_LONG_RETRY (1 << 7)
#define RT2573_TX_TKIPMIC (1 << 8)
#define RT2573_TX_KEY_PAIR (1 << 9)
#define RT2573_TX_KEY_ID(id) (((id) & 0x3f) << 10)
#define RT2573_TX_CIP_MODE(m) ((m) << 29)
uint16_t wme;
#define RT2573_QID(v) (v)
@ -182,8 +226,9 @@ struct rum_tx_desc {
#define RT2573_LOGCWMIN(v) ((v) << 8)
#define RT2573_LOGCWMAX(v) ((v) << 12)
uint16_t xflags;
#define RT2573_TX_HWSEQ (1 << 12)
uint8_t hdrlen;
uint8_t xflags;
#define RT2573_TX_HWSEQ (1 << 4)
uint8_t plcp_signal;
uint8_t plcp_service;
@ -207,9 +252,25 @@ struct rum_rx_desc {
uint32_t flags;
#define RT2573_RX_BUSY (1 << 0)
#define RT2573_RX_DROP (1 << 1)
#define RT2573_RX_UC2ME (1 << 2)
#define RT2573_RX_MC (1 << 3)
#define RT2573_RX_BC (1 << 4)
#define RT2573_RX_MYBSS (1 << 5)
#define RT2573_RX_CRC_ERROR (1 << 6)
#define RT2573_RX_OFDM (1 << 7)
#define RT2573_RX_DEC_MASK (3 << 8)
#define RT2573_RX_DEC_OK (0 << 8)
#define RT2573_RX_IV_ERROR (1 << 8)
#define RT2573_RX_MIC_ERROR (2 << 8)
#define RT2573_RX_KEY_ERROR (3 << 8)
#define RT2573_RX_KEY_PAIR (1 << 28)
#define RT2573_RX_CIP_MASK (7 << 29)
#define RT2573_RX_CIP_MODE(m) ((m) << 29)
uint8_t rate;
uint8_t rssi;
uint8_t reserved1;

View File

@ -22,6 +22,7 @@
struct rum_rx_radiotap_header {
struct ieee80211_radiotap_header wr_ihdr;
uint64_t wr_tsf;
uint8_t wr_flags;
uint8_t wr_rate;
uint16_t wr_chan_freq;
@ -32,7 +33,8 @@ struct rum_rx_radiotap_header {
} __packed __aligned(8);
#define RT2573_RX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | \
@ -42,6 +44,7 @@ struct rum_rx_radiotap_header {
struct rum_tx_radiotap_header {
struct ieee80211_radiotap_header wt_ihdr;
uint64_t wt_tsf;
uint8_t wt_flags;
uint8_t wt_rate;
uint16_t wt_chan_freq;
@ -50,7 +53,8 @@ struct rum_tx_radiotap_header {
} __packed __aligned(8);
#define RT2573_TX_RADIOTAP_PRESENT \
((1 << IEEE80211_RADIOTAP_FLAGS) | \
((1 << IEEE80211_RADIOTAP_TSFT) | \
(1 << IEEE80211_RADIOTAP_FLAGS) | \
(1 << IEEE80211_RADIOTAP_RATE) | \
(1 << IEEE80211_RADIOTAP_CHANNEL) | \
(1 << IEEE80211_RADIOTAP_ANTENNA))
@ -67,11 +71,29 @@ struct rum_tx_data {
};
typedef STAILQ_HEAD(, rum_tx_data) rum_txdhead;
union sec_param {
struct ieee80211_key key;
struct wmeParams wme_params[WME_NUM_AC];
uint8_t macaddr[IEEE80211_ADDR_LEN];
struct ieee80211vap *vap;
};
#define CMD_FUNC_PROTO void (*func)(struct rum_softc *, \
union sec_param *, uint8_t)
struct rum_cmdq {
union sec_param data;
uint8_t rvp_id;
CMD_FUNC_PROTO;
};
#define RUM_CMDQ_SIZE 16
struct rum_vap {
struct ieee80211vap vap;
struct ieee80211_beacon_offsets bo;
struct mbuf *bcn_mbuf;
struct usb_callout ratectl_ch;
struct task ratectl_task;
uint8_t maxretry;
int (*newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
@ -90,7 +112,7 @@ struct rum_softc {
device_t sc_dev;
struct usb_device *sc_udev;
struct usb_xfer *sc_xfer[RUM_N_TRANSFER];
struct usb_xfer *sc_xfer[RUM_N_TRANSFER];
uint8_t rf_rev;
uint8_t rffreq;
@ -103,11 +125,24 @@ struct rum_softc {
struct mtx sc_mtx;
struct rum_cmdq cmdq[RUM_CMDQ_SIZE];
struct mtx cmdq_mtx;
struct task cmdq_task;
uint8_t cmdq_first;
uint8_t cmdq_last;
uint32_t sta[6];
uint32_t rf_regs[4];
uint8_t txpow[44];
u_int sc_detached:1,
sc_running:1;
sc_running:1,
sc_clr_shkeys:1;
uint8_t sc_bssid[IEEE80211_ADDR_LEN];
struct wmeParams wme_params[WME_NUM_AC];
uint8_t vap_key_count[1];
uint64_t keys_bmap;
struct {
uint8_t val;
@ -125,12 +160,19 @@ struct rum_softc {
uint8_t bbp17;
struct rum_rx_radiotap_header sc_rxtap;
int sc_rxtap_len;
struct rum_tx_radiotap_header sc_txtap;
int sc_txtap_len;
};
#define RUM_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
#define RUM_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
#define RUM_LOCK_ASSERT(sc, t) mtx_assert(&(sc)->sc_mtx, t)
#define RUM_LOCK_INIT(sc) \
mtx_init(&(sc)->sc_mtx, device_get_nameunit((sc)->sc_dev), \
MTX_NETWORK_LOCK, MTX_DEF);
#define RUM_LOCK(sc) mtx_lock(&(sc)->sc_mtx)
#define RUM_UNLOCK(sc) mtx_unlock(&(sc)->sc_mtx)
#define RUM_LOCK_ASSERT(sc) mtx_assert(&(sc)->sc_mtx, MA_OWNED)
#define RUM_LOCK_DESTROY(sc) mtx_destroy(&(sc)->sc_mtx)
#define RUM_CMDQ_LOCK_INIT(sc) \
mtx_init(&(sc)->cmdq_mtx, "cmdq lock", NULL, MTX_DEF)
#define RUM_CMDQ_LOCK(sc) mtx_lock(&(sc)->cmdq_mtx)
#define RUM_CMDQ_UNLOCK(sc) mtx_unlock(&(sc)->cmdq_mtx)
#define RUM_CMDQ_LOCK_DESTROY(sc) mtx_destroy(&(sc)->cmdq_mtx)

View File

@ -382,8 +382,7 @@ static int run_newstate(struct ieee80211vap *, enum ieee80211_state, int);
static int run_wme_update(struct ieee80211com *);
static void run_wme_update_cb(void *);
static void run_key_set_cb(void *);
static int run_key_set(struct ieee80211vap *, struct ieee80211_key *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
static int run_key_set(struct ieee80211vap *, struct ieee80211_key *);
static void run_key_delete_cb(void *);
static int run_key_delete(struct ieee80211vap *, struct ieee80211_key *);
static void run_ratectl_to(void *);
@ -392,6 +391,8 @@ static void run_drain_fifo(void *);
static void run_iter_func(void *, struct ieee80211_node *);
static void run_newassoc_cb(void *);
static void run_newassoc(struct ieee80211_node *, int);
static void run_recv_mgmt(struct ieee80211_node *, struct mbuf *, int,
const struct ieee80211_rx_stats *, int, int);
static void run_rx_frame(struct run_softc *, struct mbuf *, uint32_t);
static void run_tx_free(struct run_endpoint_queue *pq,
struct run_tx_data *, int);
@ -830,6 +831,21 @@ detach:
return (ENXIO);
}
static void
run_drain_mbufq(struct run_softc *sc)
{
struct mbuf *m;
struct ieee80211_node *ni;
RUN_LOCK_ASSERT(sc, MA_OWNED);
while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
m->m_pkthdr.rcvif = NULL;
ieee80211_free_node(ni);
m_freem(m);
}
}
static int
run_detach(device_t self)
{
@ -851,6 +867,9 @@ run_detach(device_t self)
/* free TX list, if any */
for (i = 0; i != RUN_EP_QUEUES; i++)
run_unsetup_tx_list(sc, &sc->sc_epq[i]);
/* Free TX queue */
run_drain_mbufq(sc);
RUN_UNLOCK(sc);
if (sc->sc_ic.ic_softc == sc) {
@ -861,7 +880,6 @@ run_detach(device_t self)
ieee80211_ifdetach(ic);
}
mbufq_drain(&sc->sc_snd);
mtx_destroy(&sc->sc_mtx);
return (0);
@ -939,6 +957,10 @@ run_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
/* override state transition machine */
rvp->newstate = vap->iv_newstate;
vap->iv_newstate = run_newstate;
if (opmode == IEEE80211_M_IBSS) {
rvp->recv_mgmt = vap->iv_recv_mgmt;
vap->iv_recv_mgmt = run_recv_mgmt;
}
ieee80211_ratectl_init(vap);
ieee80211_ratectl_setinterval(vap, 1000 /* 1 sec */);
@ -1670,14 +1692,14 @@ run_get_txpower(struct run_softc *sc)
/* Fix broken Tx power entries. */
for (i = 0; i < 14; i++) {
if (sc->mac_ver >= 0x5390) {
if (sc->txpow1[i] < 0 || sc->txpow1[i] > 27)
if (sc->txpow1[i] < 0 || sc->txpow1[i] > 39)
sc->txpow1[i] = 5;
} else {
if (sc->txpow1[i] < 0 || sc->txpow1[i] > 31)
sc->txpow1[i] = 5;
}
if (sc->mac_ver > 0x5390) {
if (sc->txpow2[i] < 0 || sc->txpow2[i] > 27)
if (sc->txpow2[i] < 0 || sc->txpow2[i] > 39)
sc->txpow2[i] = 5;
} else if (sc->mac_ver < 0x5390) {
if (sc->txpow2[i] < 0 || sc->txpow2[i] > 31)
@ -2157,7 +2179,8 @@ run_wme_update_cb(void *arg)
{
struct ieee80211com *ic = arg;
struct run_softc *sc = ic->ic_softc;
struct ieee80211_wme_state *wmesp = &ic->ic_wme;
const struct wmeParams *ac =
ic->ic_wme.wme_chanParams.cap_wmeParams;
int aci, error = 0;
RUN_LOCK_ASSERT(sc, MA_OWNED);
@ -2165,39 +2188,39 @@ run_wme_update_cb(void *arg)
/* update MAC TX configuration registers */
for (aci = 0; aci < WME_NUM_AC; aci++) {
error = run_write(sc, RT2860_EDCA_AC_CFG(aci),
wmesp->wme_params[aci].wmep_logcwmax << 16 |
wmesp->wme_params[aci].wmep_logcwmin << 12 |
wmesp->wme_params[aci].wmep_aifsn << 8 |
wmesp->wme_params[aci].wmep_txopLimit);
ac[aci].wmep_logcwmax << 16 |
ac[aci].wmep_logcwmin << 12 |
ac[aci].wmep_aifsn << 8 |
ac[aci].wmep_txopLimit);
if (error) goto err;
}
/* update SCH/DMA registers too */
error = run_write(sc, RT2860_WMM_AIFSN_CFG,
wmesp->wme_params[WME_AC_VO].wmep_aifsn << 12 |
wmesp->wme_params[WME_AC_VI].wmep_aifsn << 8 |
wmesp->wme_params[WME_AC_BK].wmep_aifsn << 4 |
wmesp->wme_params[WME_AC_BE].wmep_aifsn);
ac[WME_AC_VO].wmep_aifsn << 12 |
ac[WME_AC_VI].wmep_aifsn << 8 |
ac[WME_AC_BK].wmep_aifsn << 4 |
ac[WME_AC_BE].wmep_aifsn);
if (error) goto err;
error = run_write(sc, RT2860_WMM_CWMIN_CFG,
wmesp->wme_params[WME_AC_VO].wmep_logcwmin << 12 |
wmesp->wme_params[WME_AC_VI].wmep_logcwmin << 8 |
wmesp->wme_params[WME_AC_BK].wmep_logcwmin << 4 |
wmesp->wme_params[WME_AC_BE].wmep_logcwmin);
ac[WME_AC_VO].wmep_logcwmin << 12 |
ac[WME_AC_VI].wmep_logcwmin << 8 |
ac[WME_AC_BK].wmep_logcwmin << 4 |
ac[WME_AC_BE].wmep_logcwmin);
if (error) goto err;
error = run_write(sc, RT2860_WMM_CWMAX_CFG,
wmesp->wme_params[WME_AC_VO].wmep_logcwmax << 12 |
wmesp->wme_params[WME_AC_VI].wmep_logcwmax << 8 |
wmesp->wme_params[WME_AC_BK].wmep_logcwmax << 4 |
wmesp->wme_params[WME_AC_BE].wmep_logcwmax);
ac[WME_AC_VO].wmep_logcwmax << 12 |
ac[WME_AC_VI].wmep_logcwmax << 8 |
ac[WME_AC_BK].wmep_logcwmax << 4 |
ac[WME_AC_BE].wmep_logcwmax);
if (error) goto err;
error = run_write(sc, RT2860_WMM_TXOP0_CFG,
wmesp->wme_params[WME_AC_BK].wmep_txopLimit << 16 |
wmesp->wme_params[WME_AC_BE].wmep_txopLimit);
ac[WME_AC_BK].wmep_txopLimit << 16 |
ac[WME_AC_BE].wmep_txopLimit);
if (error) goto err;
error = run_write(sc, RT2860_WMM_TXOP1_CFG,
wmesp->wme_params[WME_AC_VO].wmep_txopLimit << 16 |
wmesp->wme_params[WME_AC_VI].wmep_txopLimit);
ac[WME_AC_VO].wmep_txopLimit << 16 |
ac[WME_AC_VI].wmep_txopLimit);
err:
if (error)
@ -2355,8 +2378,7 @@ run_key_set_cb(void *arg)
* return 0 on error
*/
static int
run_key_set(struct ieee80211vap *vap, struct ieee80211_key *k,
const uint8_t mac[IEEE80211_ADDR_LEN])
run_key_set(struct ieee80211vap *vap, struct ieee80211_key *k)
{
struct ieee80211com *ic = vap->iv_ic;
struct run_softc *sc = ic->ic_softc;
@ -2368,7 +2390,7 @@ run_key_set(struct ieee80211vap *vap, struct ieee80211_key *k,
sc->cmdq[i].arg0 = NULL;
sc->cmdq[i].arg1 = vap;
sc->cmdq[i].k = k;
IEEE80211_ADDR_COPY(sc->cmdq[i].mac, mac);
IEEE80211_ADDR_COPY(sc->cmdq[i].mac, k->wk_macaddr);
ieee80211_runtask(ic, &sc->cmdq_task);
/*
@ -2724,6 +2746,34 @@ run_maxrssi_chain(struct run_softc *sc, const struct rt2860_rxwi *rxwi)
return (rxchain);
}
static void
run_recv_mgmt(struct ieee80211_node *ni, struct mbuf *m, int subtype,
const struct ieee80211_rx_stats *rxs, int rssi, int nf)
{
struct ieee80211vap *vap = ni->ni_vap;
struct run_softc *sc = vap->iv_ic->ic_softc;
struct run_vap *rvp = RUN_VAP(vap);
uint64_t ni_tstamp, rx_tstamp;
rvp->recv_mgmt(ni, m, subtype, rxs, rssi, nf);
if (vap->iv_state == IEEE80211_S_RUN &&
(subtype == IEEE80211_FC0_SUBTYPE_BEACON ||
subtype == IEEE80211_FC0_SUBTYPE_PROBE_RESP)) {
ni_tstamp = le64toh(ni->ni_tstamp.tsf);
RUN_LOCK(sc);
run_get_tsf(sc, &rx_tstamp);
RUN_UNLOCK(sc);
rx_tstamp = le64toh(rx_tstamp);
if (ni_tstamp >= rx_tstamp) {
DPRINTF("ibss merge, tsf %ju tstamp %ju\n",
(uintmax_t)rx_tstamp, (uintmax_t)ni_tstamp);
(void) ieee80211_ibss_merge(ni);
}
}
}
static void
run_rx_frame(struct run_softc *sc, struct mbuf *m, uint32_t dmalen)
{
@ -4834,11 +4884,11 @@ run_update_beacon(struct ieee80211vap *vap, int item)
setbit(bo->bo_flags, item);
if (rvp->beacon_mbuf == NULL) {
rvp->beacon_mbuf = ieee80211_beacon_alloc(ni, bo);
rvp->beacon_mbuf = ieee80211_beacon_alloc(ni);
if (rvp->beacon_mbuf == NULL)
return;
}
ieee80211_beacon_update(ni, bo, rvp->beacon_mbuf, mcast);
ieee80211_beacon_update(ni, rvp->beacon_mbuf, mcast);
i = RUN_CMDQ_GET(&sc->cmdq_store);
DPRINTF("cmdq_store=%d\n", i);
@ -4872,8 +4922,7 @@ run_update_beacon_cb(void *arg)
* is taking care of apropriate calls.
*/
if (rvp->beacon_mbuf == NULL) {
rvp->beacon_mbuf = ieee80211_beacon_alloc(ni,
&vap->iv_bcn_off);
rvp->beacon_mbuf = ieee80211_beacon_alloc(ni);
if (rvp->beacon_mbuf == NULL)
return;
}
@ -6140,6 +6189,8 @@ run_stop(void *arg)
RUN_LOCK(sc);
run_drain_mbufq(sc);
if (sc->rx_m != NULL) {
m_free(sc->rx_m);
sc->rx_m = NULL;

View File

@ -274,7 +274,6 @@
#define RT2860_USB_TXOP_HALT (1 << 20)
#define RT2860_USB_TX_CLEAR (1 << 19)
#define RT2860_USB_PHY_WD_EN (1 << 16)
#define RT2860_USB_PHY_MAN_RST (1 << 15)
#define RT2860_USB_RX_AGG_LMT(x) ((x) << 8) /* in unit of 1KB */
#define RT2860_USB_RX_AGG_TO(x) ((x) & 0xff) /* in unit of 33ns */

View File

@ -123,6 +123,10 @@ struct run_vap {
int (*newstate)(struct ieee80211vap *,
enum ieee80211_state, int);
void (*recv_mgmt)(struct ieee80211_node *,
struct mbuf *, int,
const struct ieee80211_rx_stats *,
int, int);
uint8_t rvp_id;
};

View File

@ -956,10 +956,7 @@ upgt_vap_create(struct ieee80211com *ic, const char name[IFNAMSIZ], int unit,
if (!TAILQ_EMPTY(&ic->ic_vaps)) /* only one at a time */
return NULL;
uvp = (struct upgt_vap *) malloc(sizeof(struct upgt_vap),
M_80211_VAP, M_NOWAIT | M_ZERO);
if (uvp == NULL)
return NULL;
uvp = malloc(sizeof(struct upgt_vap), M_80211_VAP, M_WAITOK | M_ZERO);
vap = &uvp->vap;
/* enable s/w bmiss handling for sta mode */

View File

@ -698,12 +698,9 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
ni = ieee80211_ref_node(vap->iv_bss);
if (vap->iv_opmode != IEEE80211_M_MONITOR) {
if (ic->ic_bsschan == IEEE80211_CHAN_ANYC) {
RAL_UNLOCK(sc);
IEEE80211_LOCK(ic);
ieee80211_free_node(ni);
return (-1);
}
if (ic->ic_bsschan == IEEE80211_CHAN_ANYC)
goto fail;
ural_update_slot(sc);
ural_set_txpreamble(sc);
ural_set_basicrates(sc, ic->ic_bsschan);
@ -713,23 +710,17 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
if (vap->iv_opmode == IEEE80211_M_HOSTAP ||
vap->iv_opmode == IEEE80211_M_IBSS) {
m = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off);
m = ieee80211_beacon_alloc(ni);
if (m == NULL) {
device_printf(sc->sc_dev,
"could not allocate beacon\n");
RAL_UNLOCK(sc);
IEEE80211_LOCK(ic);
ieee80211_free_node(ni);
return (-1);
goto fail;
}
ieee80211_ref_node(ni);
if (ural_tx_bcn(sc, m, ni) != 0) {
device_printf(sc->sc_dev,
"could not send beacon\n");
RAL_UNLOCK(sc);
IEEE80211_LOCK(ic);
ieee80211_free_node(ni);
return (-1);
goto fail;
}
}
@ -755,6 +746,12 @@ ural_newstate(struct ieee80211vap *vap, enum ieee80211_state nstate, int arg)
RAL_UNLOCK(sc);
IEEE80211_LOCK(ic);
return (uvp->newstate(vap, nstate, arg));
fail:
RAL_UNLOCK(sc);
IEEE80211_LOCK(ic);
ieee80211_free_node(ni);
return (-1);
}

View File

@ -1775,7 +1775,7 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
struct r92c_tx_desc *txd;
uint8_t raid, type;
uint16_t sum;
int i, hasqos, xferlen;
int i, xferlen;
struct usb_xfer *urtwn_pipes[4] = {
sc->sc_xfer[URTWN_BULK_TX_BE],
sc->sc_xfer[URTWN_BULK_TX_BK],
@ -1816,8 +1816,6 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
break;
}
hasqos = 0;
/* Fill Tx descriptor. */
txd = (struct r92c_tx_desc *)data->buf;
memset(txd, 0, sizeof(*txd));
@ -1873,7 +1871,7 @@ urtwn_tx_start(struct urtwn_softc *sc, struct ieee80211_node *ni,
/* Set sequence number (already little endian). */
txd->txdseq |= *(uint16_t *)wh->i_seq;
if (!hasqos) {
if (!IEEE80211_QOS_HAS_SEQ(wh)) {
/* Use HW sequence numbering for non-QoS frames. */
txd->txdw4 |= htole32(R92C_TXDW4_HWSEQ);
txd->txdseq |= htole16(0x8000);

View File

@ -420,6 +420,22 @@ detach:
return (ENXIO); /* failure */
}
static void
zyd_drain_mbufq(struct zyd_softc *sc)
{
struct mbuf *m;
struct ieee80211_node *ni;
ZYD_LOCK_ASSERT(sc, MA_OWNED);
while ((m = mbufq_dequeue(&sc->sc_snd)) != NULL) {
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
m->m_pkthdr.rcvif = NULL;
ieee80211_free_node(ni);
m_freem(m);
}
}
static int
zyd_detach(device_t dev)
{
@ -433,6 +449,7 @@ zyd_detach(device_t dev)
*/
ZYD_LOCK(sc);
sc->sc_flags |= ZYD_FLAG_DETACHED;
zyd_drain_mbufq(sc);
STAILQ_INIT(&sc->tx_q);
STAILQ_INIT(&sc->tx_free);
ZYD_UNLOCK(sc);
@ -451,7 +468,6 @@ zyd_detach(device_t dev)
if (ic->ic_softc == sc)
ieee80211_ifdetach(ic);
mbufq_drain(&sc->sc_snd);
mtx_destroy(&sc->sc_mtx);
return (0);
@ -2443,7 +2459,6 @@ zyd_tx_start(struct zyd_softc *sc, struct mbuf *m0, struct ieee80211_node *ni)
if (wh->i_fc[1] & IEEE80211_FC1_PROTECTED) {
k = ieee80211_crypto_encap(ni, m0);
if (k == NULL) {
m_freem(m0);
return (ENOBUFS);
}
/* packet header may have moved, reset our local pointer */
@ -2555,6 +2570,7 @@ zyd_start(struct zyd_softc *sc)
ni = (struct ieee80211_node *)m->m_pkthdr.rcvif;
if (zyd_tx_start(sc, m, ni) != 0) {
ieee80211_free_node(ni);
m_freem(m);
if_inc_counter(ni->ni_vap->iv_ifp,
IFCOUNTER_OERRORS, 1);
break;
@ -2592,6 +2608,7 @@ zyd_raw_xmit(struct ieee80211_node *ni, struct mbuf *m,
if (zyd_tx_start(sc, m, ni) != 0) {
ZYD_UNLOCK(sc);
ieee80211_free_node(ni);
m_freem(m);
return (EIO);
}
ZYD_UNLOCK(sc);
@ -2738,6 +2755,7 @@ zyd_stop(struct zyd_softc *sc)
ZYD_LOCK_ASSERT(sc, MA_OWNED);
sc->sc_flags &= ~ZYD_FLAG_RUNNING;
zyd_drain_mbufq(sc);
/*
* Drain all the transfers, if not already drained:

View File

@ -254,8 +254,7 @@ static void wpi_del_key_cb(void *, struct ieee80211_node *);
static int wpi_process_key(struct ieee80211vap *,
const struct ieee80211_key *, int);
static int wpi_key_set(struct ieee80211vap *,
const struct ieee80211_key *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
const struct ieee80211_key *);
static int wpi_key_delete(struct ieee80211vap *,
const struct ieee80211_key *);
static int wpi_post_alive(struct wpi_softc *);
@ -4355,7 +4354,6 @@ static int
wpi_setup_beacon(struct wpi_softc *sc, struct ieee80211_node *ni)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct wpi_vap *wvp = WPI_VAP(vap);
struct wpi_buf *bcn = &wvp->wv_bcbuf;
struct mbuf *m;
@ -4366,7 +4364,7 @@ wpi_setup_beacon(struct wpi_softc *sc, struct ieee80211_node *ni)
if (ni->ni_chan == IEEE80211_CHAN_ANYC)
return EINVAL;
m = ieee80211_beacon_alloc(ni, bo);
m = ieee80211_beacon_alloc(ni);
if (m == NULL) {
device_printf(sc->sc_dev,
"%s: could not allocate beacon frame\n", __func__);
@ -4399,7 +4397,7 @@ wpi_update_beacon(struct ieee80211vap *vap, int item)
WPI_VAP_LOCK(wvp);
if (bcn->m == NULL) {
bcn->m = ieee80211_beacon_alloc(ni, bo);
bcn->m = ieee80211_beacon_alloc(ni);
if (bcn->m == NULL) {
device_printf(sc->sc_dev,
"%s: could not allocate beacon frame\n", __func__);
@ -4417,7 +4415,7 @@ wpi_update_beacon(struct ieee80211vap *vap, int item)
mcast = 1; /* TODO */
setbit(bo->bo_flags, item);
ieee80211_beacon_update(ni, bo, bcn->m, mcast);
ieee80211_beacon_update(ni, bcn->m, mcast);
WPI_VAP_LOCK(wvp);
wpi_config_beacon(wvp);
@ -4799,8 +4797,7 @@ wpi_process_key(struct ieee80211vap *vap, const struct ieee80211_key *k,
}
static int
wpi_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k,
const uint8_t mac[IEEE80211_ADDR_LEN])
wpi_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
return wpi_process_key(vap, k, 1);
}

View File

@ -205,7 +205,7 @@ wtap_beacon_alloc(struct wtap_softc *sc, struct ieee80211_node *ni)
* we assume the mbuf routines will return us something
* with this alignment (perhaps should assert).
*/
avp->beacon = ieee80211_beacon_alloc(ni, &vap->iv_bcn_off);
avp->beacon = ieee80211_beacon_alloc(ni);
if (avp->beacon == NULL) {
printf("%s: cannot get mbuf\n", __func__);
return ENOMEM;
@ -242,7 +242,7 @@ wtap_beacon_intrp(void *arg)
* of the TIM bitmap).
*/
m = m_dup(avp->beacon, M_NOWAIT);
if (ieee80211_beacon_update(avp->bf_node, &vap->iv_bcn_off, m, 0)) {
if (ieee80211_beacon_update(avp->bf_node, m, 0)) {
printf("%s, need to remap the memory because the beacon frame"
" changed size.\n",__func__);
}

View File

@ -623,6 +623,10 @@ sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap)
va_copy(ap_copy, ap);
len = vsnprintf(&s->s_buf[s->s_len], SBUF_FREESPACE(s) + 1,
fmt, ap_copy);
if (len < 0) {
s->s_error = errno;
return (-1);
}
va_end(ap_copy);
if (SBUF_FREESPACE(s) >= len)

View File

@ -2050,11 +2050,10 @@ vfs_vmio_iodone(struct buf *bp)
(intmax_t)foff, (uintmax_t)m->pindex));
vm_page_sunbusy(m);
vm_object_pip_subtract(obj, 1);
foff = (foff + PAGE_SIZE) & ~(off_t)PAGE_MASK;
iosize -= resid;
}
vm_object_pip_wakeupn(obj, 0);
vm_object_pip_wakeupn(obj, bp->b_npages);
VM_OBJECT_WUNLOCK(obj);
if (bogus && buf_mapped(bp)) {
BUF_CHECK_MAPPED(bp);
@ -3923,10 +3922,9 @@ vfs_unbusy_pages(struct buf *bp)
} else
BUF_CHECK_UNMAPPED(bp);
}
vm_object_pip_subtract(obj, 1);
vm_page_sunbusy(m);
}
vm_object_pip_wakeupn(obj, 0);
vm_object_pip_wakeupn(obj, bp->b_npages);
VM_OBJECT_WUNLOCK(obj);
}

View File

@ -28,9 +28,6 @@ device geom_uncompress # compressed in-memory filesystem hackery!
options ROOTDEVNAME=\"ufs:/dev/map/rootfs.uncompress\"
# options MD_ROOT
# options MD_ROOT_SIZE="6144"
options AR71XX_ATH_EEPROM # Fetch EEPROM/PCI config from flash
options ATH_EEPROM_FIRMWARE # Use EEPROM from flash
device firmware # Used by the above
@ -42,10 +39,11 @@ device miiproxy # MDIO bus <-> MII PHY rendezvous
device etherswitch
device arswitch
# Enable GPIO
device gpio
device gpioled
# hwpmc
device hwpmc_mips24k
device hwpmc
# load these via modules, shrink kernel
nodevice if_bridge
nodevice bridgestp
nodevice random

View File

@ -5,11 +5,11 @@
# arge1 MDIO bus
hint.argemdio.0.at="nexus0"
hint.argemdio.0.maddr=0x1a000000
hint.argemdio.0.maddr=0x19000000
hint.argemdio.0.msize=0x1000
hint.argemdio.0.order=0
hint.arge.0.phymask=0x0
hint.arge.0.phymask=0x1
hint.arge.0.media=1000
hint.arge.0.fduplex=1
hint.arge.0.eeprommac=0x1f05120c
@ -17,9 +17,9 @@ hint.arge.0.mdio=mdioproxy1 # .. off of the switch mdiobus
# arge1: nail to 1000/full, RMII - connected to the switch
hint.arge.1.media=1000 # Map to 1000/full
hint.arge.1.fduplex=1 #
hint.arge.1.phymask=0x0 # no directly mapped PHYs
#hint.arge.1.media=1000 # Map to 1000/full
#hint.arge.1.fduplex=1 #
#hint.arge.1.phymask=0x0 # no directly mapped PHYs
#
# AR7240 switch config
@ -28,7 +28,7 @@ hint.arswitch.0.at="mdio0"
hint.arswitch.0.is_7240=1 # We need to be explicitly told this
hint.arswitch.0.numphys=4 # 4 active switch PHYs (PHY 0 -> 3)
hint.arswitch.0.phy4cpu=1 # Yes, PHY 4 == dedicated PHY
hint.arswitch.0.is_rgmii=0 # No, not RGMII
hint.arswitch.0.is_rgmii=1 # No, not RGMII
hint.arswitch.0.is_gmii=0 # No, not GMII
# ath0 - slot 0

View File

@ -197,6 +197,8 @@ gif_clone_create(struct if_clone *ifc, int unit, caddr_t params)
GIF2IFP(sc)->if_transmit = gif_transmit;
GIF2IFP(sc)->if_qflush = gif_qflush;
GIF2IFP(sc)->if_output = gif_output;
GIF2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
GIF2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(GIF2IFP(sc));
bpfattach(GIF2IFP(sc), DLT_NULL, sizeof(u_int32_t));
if (ng_gif_attach_p != NULL)
@ -1040,10 +1042,13 @@ gif_set_tunnel(struct ifnet *ifp, struct sockaddr *src, struct sockaddr *dst)
#if defined(INET) || defined(INET6)
bad:
#endif
if (error == 0 && sc->gif_family != 0)
if (error == 0 && sc->gif_family != 0) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
else
if_link_state_change(ifp, LINK_STATE_UP);
} else {
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_DOWN);
}
return (error);
}
@ -1065,4 +1070,5 @@ gif_delete_tunnel(struct ifnet *ifp)
free(sc->gif_hdr, M_GIF);
}
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_DOWN);
}

View File

@ -179,6 +179,8 @@ gre_clone_create(struct if_clone *ifc, int unit, caddr_t params)
GRE2IFP(sc)->if_ioctl = gre_ioctl;
GRE2IFP(sc)->if_transmit = gre_transmit;
GRE2IFP(sc)->if_qflush = gre_qflush;
GRE2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
GRE2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(GRE2IFP(sc));
bpfattach(GRE2IFP(sc), DLT_NULL, sizeof(u_int32_t));
GRE_LIST_LOCK();
@ -623,7 +625,7 @@ gre_set_tunnel(struct ifnet *ifp, struct sockaddr *src,
default:
return (EAFNOSUPPORT);
}
if (sc->gre_family != src->sa_family)
if (sc->gre_family != 0)
gre_detach(sc);
GRE_WLOCK(sc);
if (sc->gre_family != 0)
@ -648,8 +650,10 @@ gre_set_tunnel(struct ifnet *ifp, struct sockaddr *src,
break;
#endif
}
if (error == 0)
if (error == 0) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_UP);
}
return (error);
}
@ -668,6 +672,7 @@ gre_delete_tunnel(struct ifnet *ifp)
free(sc->gre_hdr, M_GRE);
}
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_DOWN);
}
int

View File

@ -220,13 +220,6 @@ static const struct lagg_proto {
.pr_request = lacp_req,
.pr_portreq = lacp_portreq,
},
{
.pr_num = LAGG_PROTO_ETHERCHANNEL,
.pr_attach = lagg_lb_attach,
.pr_detach = lagg_lb_detach,
.pr_start = lagg_lb_start,
.pr_input = lagg_lb_input,
},
{
.pr_num = LAGG_PROTO_BROADCAST,
.pr_start = lagg_bcast_start,
@ -1125,7 +1118,6 @@ lagg_port2req(struct lagg_port *lp, struct lagg_reqport *rp)
case LAGG_PROTO_ROUNDROBIN:
case LAGG_PROTO_LOADBALANCE:
case LAGG_PROTO_ETHERCHANNEL:
case LAGG_PROTO_BROADCAST:
if (LAGG_PORTACTIVE(lp))
rp->rp_flags |= LAGG_PORT_ACTIVE;
@ -1759,7 +1751,6 @@ lagg_linkstate(struct lagg_softc *sc)
break;
case LAGG_PROTO_ROUNDROBIN:
case LAGG_PROTO_LOADBALANCE:
case LAGG_PROTO_ETHERCHANNEL:
case LAGG_PROTO_BROADCAST:
speed = 0;
SLIST_FOREACH(lp, &sc->sc_ports, lp_entries)

View File

@ -53,7 +53,6 @@ typedef enum {
LAGG_PROTO_FAILOVER, /* active failover */
LAGG_PROTO_LOADBALANCE, /* loadbalance */
LAGG_PROTO_LACP, /* 802.3ad lacp */
LAGG_PROTO_ETHERCHANNEL,/* Cisco FEC */
LAGG_PROTO_BROADCAST, /* broadcast */
LAGG_PROTO_MAX,
} lagg_proto;
@ -66,7 +65,6 @@ struct lagg_protos {
#define LAGG_PROTO_DEFAULT LAGG_PROTO_FAILOVER
#define LAGG_PROTOS { \
{ "failover", LAGG_PROTO_FAILOVER }, \
{ "fec", LAGG_PROTO_ETHERCHANNEL }, \
{ "lacp", LAGG_PROTO_LACP }, \
{ "loadbalance", LAGG_PROTO_LOADBALANCE }, \
{ "roundrobin", LAGG_PROTO_ROUNDROBIN }, \

View File

@ -192,6 +192,8 @@ me_clone_create(struct if_clone *ifc, int unit, caddr_t params)
ME2IFP(sc)->if_ioctl = me_ioctl;
ME2IFP(sc)->if_transmit = me_transmit;
ME2IFP(sc)->if_qflush = me_qflush;
ME2IFP(sc)->if_capabilities |= IFCAP_LINKSTATE;
ME2IFP(sc)->if_capenable |= IFCAP_LINKSTATE;
if_attach(ME2IFP(sc));
bpfattach(ME2IFP(sc), DLT_NULL, sizeof(u_int32_t));
ME_LIST_LOCK();
@ -376,8 +378,10 @@ me_set_tunnel(struct ifnet *ifp, struct sockaddr_in *src,
if (sc->me_ecookie == NULL)
sc->me_ecookie = encap_attach_func(AF_INET, IPPROTO_MOBILE,
me_encapcheck, &in_mobile_protosw, sc);
if (sc->me_ecookie != NULL)
if (sc->me_ecookie != NULL) {
ifp->if_drv_flags |= IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_UP);
}
return (0);
}
@ -395,6 +399,7 @@ me_delete_tunnel(struct ifnet *ifp)
sc->me_dst.s_addr = 0;
ME_WUNLOCK(sc);
ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
if_link_state_change(ifp, LINK_STATE_DOWN);
}
static uint16_t

View File

@ -89,8 +89,7 @@ null_key_delete(struct ieee80211vap *vap, const struct ieee80211_key *k)
return 1;
}
static int
null_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k,
const uint8_t mac[IEEE80211_ADDR_LEN])
null_key_set(struct ieee80211vap *vap, const struct ieee80211_key *k)
{
return 1;
}
@ -132,7 +131,7 @@ dev_key_delete(struct ieee80211vap *vap,
static __inline int
dev_key_set(struct ieee80211vap *vap, const struct ieee80211_key *key)
{
return vap->iv_key_set(vap, key, key->wk_macaddr);
return vap->iv_key_set(vap, key);
}
/*
@ -521,17 +520,21 @@ ieee80211_crypto_setkey(struct ieee80211vap *vap, struct ieee80211_key *key)
return dev_key_set(vap, key);
}
/*
* Add privacy headers appropriate for the specified key.
*/
uint8_t
ieee80211_crypto_get_keyid(struct ieee80211vap *vap, struct ieee80211_key *k)
{
if (k >= &vap->iv_nw_keys[0] &&
k < &vap->iv_nw_keys[IEEE80211_WEP_NKID])
return (k - vap->iv_nw_keys);
else
return (0);
}
struct ieee80211_key *
ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
ieee80211_crypto_get_txkey(struct ieee80211_node *ni, struct mbuf *m)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211_key *k;
struct ieee80211_frame *wh;
const struct ieee80211_cipher *cip;
uint8_t keyid;
/*
* Multicast traffic always uses the multicast key.
@ -550,14 +553,27 @@ ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
vap->iv_stats.is_tx_nodefkey++;
return NULL;
}
keyid = vap->iv_def_txkey;
k = &vap->iv_nw_keys[vap->iv_def_txkey];
} else {
keyid = 0;
k = &ni->ni_ucastkey;
return &vap->iv_nw_keys[vap->iv_def_txkey];
}
cip = k->wk_cipher;
return (cip->ic_encap(k, m, keyid<<6) ? k : NULL);
return &ni->ni_ucastkey;
}
/*
* Add privacy headers appropriate for the specified key.
*/
struct ieee80211_key *
ieee80211_crypto_encap(struct ieee80211_node *ni, struct mbuf *m)
{
struct ieee80211_key *k;
const struct ieee80211_cipher *cip;
if ((k = ieee80211_crypto_get_txkey(ni, m)) != NULL) {
cip = k->wk_cipher;
return (cip->ic_encap(k, m) ? k : NULL);
}
return NULL;
}
/*

View File

@ -178,8 +178,8 @@ struct ieee80211_cipher {
void* (*ic_attach)(struct ieee80211vap *, struct ieee80211_key *);
void (*ic_detach)(struct ieee80211_key *);
int (*ic_setkey)(struct ieee80211_key *);
int (*ic_encap)(struct ieee80211_key *, struct mbuf *,
uint8_t keyid);
void (*ic_setiv)(struct ieee80211_key *, uint8_t *);
int (*ic_encap)(struct ieee80211_key *, struct mbuf *);
int (*ic_decap)(struct ieee80211_key *, struct mbuf *, int);
int (*ic_enmic)(struct ieee80211_key *, struct mbuf *, int);
int (*ic_demic)(struct ieee80211_key *, struct mbuf *, int);
@ -193,6 +193,10 @@ void ieee80211_crypto_register(const struct ieee80211_cipher *);
void ieee80211_crypto_unregister(const struct ieee80211_cipher *);
int ieee80211_crypto_available(u_int cipher);
uint8_t ieee80211_crypto_get_keyid(struct ieee80211vap *vap,
struct ieee80211_key *k);
struct ieee80211_key *ieee80211_crypto_get_txkey(struct ieee80211_node *,
struct mbuf *);
struct ieee80211_key *ieee80211_crypto_encap(struct ieee80211_node *,
struct mbuf *);
struct ieee80211_key *ieee80211_crypto_decap(struct ieee80211_node *,

View File

@ -63,7 +63,8 @@ struct ccmp_ctx {
static void *ccmp_attach(struct ieee80211vap *, struct ieee80211_key *);
static void ccmp_detach(struct ieee80211_key *);
static int ccmp_setkey(struct ieee80211_key *);
static int ccmp_encap(struct ieee80211_key *k, struct mbuf *, uint8_t keyid);
static void ccmp_setiv(struct ieee80211_key *, uint8_t *);
static int ccmp_encap(struct ieee80211_key *, struct mbuf *);
static int ccmp_decap(struct ieee80211_key *, struct mbuf *, int);
static int ccmp_enmic(struct ieee80211_key *, struct mbuf *, int);
static int ccmp_demic(struct ieee80211_key *, struct mbuf *, int);
@ -78,6 +79,7 @@ static const struct ieee80211_cipher ccmp = {
.ic_attach = ccmp_attach,
.ic_detach = ccmp_detach,
.ic_setkey = ccmp_setkey,
.ic_setiv = ccmp_setiv,
.ic_encap = ccmp_encap,
.ic_decap = ccmp_decap,
.ic_enmic = ccmp_enmic,
@ -134,11 +136,31 @@ ccmp_setkey(struct ieee80211_key *k)
return 1;
}
static void
ccmp_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
struct ccmp_ctx *ctx = k->wk_private;
struct ieee80211vap *vap = ctx->cc_vap;
uint8_t keyid;
keyid = ieee80211_crypto_get_keyid(vap, k) << 6;
k->wk_keytsc++;
ivp[0] = k->wk_keytsc >> 0; /* PN0 */
ivp[1] = k->wk_keytsc >> 8; /* PN1 */
ivp[2] = 0; /* Reserved */
ivp[3] = keyid | IEEE80211_WEP_EXTIV; /* KeyID | ExtID */
ivp[4] = k->wk_keytsc >> 16; /* PN2 */
ivp[5] = k->wk_keytsc >> 24; /* PN3 */
ivp[6] = k->wk_keytsc >> 32; /* PN4 */
ivp[7] = k->wk_keytsc >> 40; /* PN5 */
}
/*
* Add privacy headers appropriate for the specified key.
*/
static int
ccmp_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
ccmp_encap(struct ieee80211_key *k, struct mbuf *m)
{
struct ccmp_ctx *ctx = k->wk_private;
struct ieee80211com *ic = ctx->cc_ic;
@ -157,18 +179,10 @@ ccmp_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
ovbcopy(ivp + ccmp.ic_header, ivp, hdrlen);
ivp += hdrlen;
k->wk_keytsc++; /* XXX wrap at 48 bits */
ivp[0] = k->wk_keytsc >> 0; /* PN0 */
ivp[1] = k->wk_keytsc >> 8; /* PN1 */
ivp[2] = 0; /* Reserved */
ivp[3] = keyid | IEEE80211_WEP_EXTIV; /* KeyID | ExtID */
ivp[4] = k->wk_keytsc >> 16; /* PN2 */
ivp[5] = k->wk_keytsc >> 24; /* PN3 */
ivp[6] = k->wk_keytsc >> 32; /* PN4 */
ivp[7] = k->wk_keytsc >> 40; /* PN5 */
ccmp_setiv(k, ivp);
/*
* Finally, do software encrypt if neeed.
* Finally, do software encrypt if needed.
*/
if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
!ccmp_encrypt(k, m, hdrlen))

View File

@ -48,7 +48,8 @@ __FBSDID("$FreeBSD$");
static void *none_attach(struct ieee80211vap *, struct ieee80211_key *);
static void none_detach(struct ieee80211_key *);
static int none_setkey(struct ieee80211_key *);
static int none_encap(struct ieee80211_key *, struct mbuf *, uint8_t);
static void none_setiv(struct ieee80211_key *, uint8_t *);
static int none_encap(struct ieee80211_key *, struct mbuf *);
static int none_decap(struct ieee80211_key *, struct mbuf *, int);
static int none_enmic(struct ieee80211_key *, struct mbuf *, int);
static int none_demic(struct ieee80211_key *, struct mbuf *, int);
@ -62,6 +63,7 @@ const struct ieee80211_cipher ieee80211_cipher_none = {
.ic_attach = none_attach,
.ic_detach = none_detach,
.ic_setkey = none_setkey,
.ic_setiv = none_setiv,
.ic_encap = none_encap,
.ic_decap = none_decap,
.ic_enmic = none_enmic,
@ -87,20 +89,28 @@ none_setkey(struct ieee80211_key *k)
return 1;
}
static void
none_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
}
static int
none_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
none_encap(struct ieee80211_key *k, struct mbuf *m)
{
struct ieee80211vap *vap = k->wk_private;
#ifdef IEEE80211_DEBUG
struct ieee80211_frame *wh = mtod(m, struct ieee80211_frame *);
#endif
uint8_t keyid;
keyid = ieee80211_crypto_get_keyid(vap, k);
/*
* The specified key is not setup; this can
* happen, at least, when changing keys.
*/
IEEE80211_NOTE_MAC(vap, IEEE80211_MSG_CRYPTO, wh->i_addr1,
"key id %u is not set (encap)", keyid>>6);
"key id %u is not set (encap)", keyid);
vap->iv_stats.is_tx_badcipher++;
return 0;
}

View File

@ -54,7 +54,8 @@ __FBSDID("$FreeBSD$");
static void *tkip_attach(struct ieee80211vap *, struct ieee80211_key *);
static void tkip_detach(struct ieee80211_key *);
static int tkip_setkey(struct ieee80211_key *);
static int tkip_encap(struct ieee80211_key *, struct mbuf *m, uint8_t keyid);
static void tkip_setiv(struct ieee80211_key *, uint8_t *);
static int tkip_encap(struct ieee80211_key *, struct mbuf *);
static int tkip_enmic(struct ieee80211_key *, struct mbuf *, int);
static int tkip_decap(struct ieee80211_key *, struct mbuf *, int);
static int tkip_demic(struct ieee80211_key *, struct mbuf *, int);
@ -69,6 +70,7 @@ static const struct ieee80211_cipher tkip = {
.ic_attach = tkip_attach,
.ic_detach = tkip_detach,
.ic_setkey = tkip_setkey,
.ic_setiv = tkip_setiv,
.ic_encap = tkip_encap,
.ic_decap = tkip_decap,
.ic_enmic = tkip_enmic,
@ -84,7 +86,6 @@ struct tkip_ctx {
struct ieee80211vap *tc_vap; /* for diagnostics+statistics */
u16 tx_ttak[5];
int tx_phase1_done;
u8 tx_rc4key[16]; /* XXX for test module; make locals? */
u16 rx_ttak[5];
@ -143,16 +144,35 @@ tkip_setkey(struct ieee80211_key *k)
__func__, k->wk_keylen, 128/NBBY);
return 0;
}
k->wk_keytsc = 1; /* TSC starts at 1 */
ctx->rx_phase1_done = 0;
return 1;
}
static void
tkip_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
struct tkip_ctx *ctx = k->wk_private;
struct ieee80211vap *vap = ctx->tc_vap;
uint8_t keyid;
keyid = ieee80211_crypto_get_keyid(vap, k) << 6;
k->wk_keytsc++;
ivp[0] = k->wk_keytsc >> 8; /* TSC1 */
ivp[1] = (ivp[0] | 0x20) & 0x7f; /* WEP seed */
ivp[2] = k->wk_keytsc >> 0; /* TSC0 */
ivp[3] = keyid | IEEE80211_WEP_EXTIV; /* KeyID | ExtID */
ivp[4] = k->wk_keytsc >> 16; /* TSC2 */
ivp[5] = k->wk_keytsc >> 24; /* TSC3 */
ivp[6] = k->wk_keytsc >> 32; /* TSC4 */
ivp[7] = k->wk_keytsc >> 40; /* TSC5 */
}
/*
* Add privacy headers and do any s/w encryption required.
*/
static int
tkip_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
tkip_encap(struct ieee80211_key *k, struct mbuf *m)
{
struct tkip_ctx *ctx = k->wk_private;
struct ieee80211vap *vap = ctx->tc_vap;
@ -185,24 +205,14 @@ tkip_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
memmove(ivp, ivp + tkip.ic_header, hdrlen);
ivp += hdrlen;
ivp[0] = k->wk_keytsc >> 8; /* TSC1 */
ivp[1] = (ivp[0] | 0x20) & 0x7f; /* WEP seed */
ivp[2] = k->wk_keytsc >> 0; /* TSC0 */
ivp[3] = keyid | IEEE80211_WEP_EXTIV; /* KeyID | ExtID */
ivp[4] = k->wk_keytsc >> 16; /* TSC2 */
ivp[5] = k->wk_keytsc >> 24; /* TSC3 */
ivp[6] = k->wk_keytsc >> 32; /* TSC4 */
ivp[7] = k->wk_keytsc >> 40; /* TSC5 */
tkip_setiv(k, ivp);
/*
* Finally, do software encrypt if neeed.
* Finally, do software encrypt if needed.
*/
if (k->wk_flags & IEEE80211_KEY_SWENCRYPT) {
if (!tkip_encrypt(ctx, k, m, hdrlen))
return 0;
/* NB: tkip_encrypt handles wk_keytsc */
} else
k->wk_keytsc++;
if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
!tkip_encrypt(ctx, k, m, hdrlen))
return 0;
return 1;
}
@ -931,10 +941,9 @@ tkip_encrypt(struct tkip_ctx *ctx, struct ieee80211_key *key,
ctx->tc_vap->iv_stats.is_crypto_tkip++;
wh = mtod(m, struct ieee80211_frame *);
if (!ctx->tx_phase1_done) {
if ((u16)(key->wk_keytsc) == 0 || key->wk_keytsc == 1) {
tkip_mixing_phase1(ctx->tx_ttak, key->wk_key, wh->i_addr2,
(u32)(key->wk_keytsc >> 16));
ctx->tx_phase1_done = 1;
}
tkip_mixing_phase2(ctx->tx_rc4key, key->wk_key, ctx->tx_ttak,
(u16) key->wk_keytsc);
@ -945,9 +954,6 @@ tkip_encrypt(struct tkip_ctx *ctx, struct ieee80211_key *key,
icv);
(void) m_append(m, IEEE80211_WEP_CRCLEN, icv); /* XXX check return */
key->wk_keytsc++;
if ((u16)(key->wk_keytsc) == 0)
ctx->tx_phase1_done = 0;
return 1;
}

View File

@ -50,8 +50,9 @@ __FBSDID("$FreeBSD$");
static void *wep_attach(struct ieee80211vap *, struct ieee80211_key *);
static void wep_detach(struct ieee80211_key *);
static int wep_setkey(struct ieee80211_key *);
static int wep_encap(struct ieee80211_key *, struct mbuf *, uint8_t keyid);
static int wep_decap(struct ieee80211_key *, struct mbuf *, int hdrlen);
static void wep_setiv(struct ieee80211_key *, uint8_t *);
static int wep_encap(struct ieee80211_key *, struct mbuf *);
static int wep_decap(struct ieee80211_key *, struct mbuf *, int);
static int wep_enmic(struct ieee80211_key *, struct mbuf *, int);
static int wep_demic(struct ieee80211_key *, struct mbuf *, int);
@ -64,6 +65,7 @@ static const struct ieee80211_cipher wep = {
.ic_attach = wep_attach,
.ic_detach = wep_detach,
.ic_setkey = wep_setkey,
.ic_setiv = wep_setiv,
.ic_encap = wep_encap,
.ic_decap = wep_decap,
.ic_enmic = wep_enmic,
@ -117,29 +119,15 @@ wep_setkey(struct ieee80211_key *k)
return k->wk_keylen >= 40/NBBY;
}
/*
* Add privacy headers appropriate for the specified key.
*/
static int
wep_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
static void
wep_setiv(struct ieee80211_key *k, uint8_t *ivp)
{
struct wep_ctx *ctx = k->wk_private;
struct ieee80211com *ic = ctx->wc_ic;
struct ieee80211vap *vap = ctx->wc_vap;
uint32_t iv;
uint8_t *ivp;
int hdrlen;
uint8_t keyid;
hdrlen = ieee80211_hdrspace(ic, mtod(m, void *));
/*
* Copy down 802.11 header and add the IV + KeyID.
*/
M_PREPEND(m, wep.ic_header, M_NOWAIT);
if (m == NULL)
return 0;
ivp = mtod(m, uint8_t *);
ovbcopy(ivp + wep.ic_header, ivp, hdrlen);
ivp += hdrlen;
keyid = ieee80211_crypto_get_keyid(vap, k) << 6;
/*
* XXX
@ -182,9 +170,35 @@ wep_encap(struct ieee80211_key *k, struct mbuf *m, uint8_t keyid)
ivp[0] = iv >> 16;
#endif
ivp[3] = keyid;
}
/*
* Add privacy headers appropriate for the specified key.
*/
static int
wep_encap(struct ieee80211_key *k, struct mbuf *m)
{
struct wep_ctx *ctx = k->wk_private;
struct ieee80211com *ic = ctx->wc_ic;
uint8_t *ivp;
int hdrlen;
hdrlen = ieee80211_hdrspace(ic, mtod(m, void *));
/*
* Finally, do software encrypt if neeed.
* Copy down 802.11 header and add the IV + KeyID.
*/
M_PREPEND(m, wep.ic_header, M_NOWAIT);
if (m == NULL)
return 0;
ivp = mtod(m, uint8_t *);
ovbcopy(ivp + wep.ic_header, ivp, hdrlen);
ivp += hdrlen;
wep_setiv(k, ivp);
/*
* Finally, do software encrypt if needed.
*/
if ((k->wk_flags & IEEE80211_KEY_SWENCRYPT) &&
!wep_encrypt(k, m, hdrlen))

View File

@ -957,7 +957,7 @@ ieee80211_ioctl_get80211(struct ieee80211vap *vap, u_long cmd,
case IEEE80211_IOC_WME_AIFS: /* WME: AIFS */
case IEEE80211_IOC_WME_TXOPLIMIT: /* WME: txops limit */
case IEEE80211_IOC_WME_ACM: /* WME: ACM (bss only) */
case IEEE80211_IOC_WME_ACKPOLICY: /* WME: ACK policy (bss only) */
case IEEE80211_IOC_WME_ACKPOLICY: /* WME: ACK policy (!bss only) */
error = ieee80211_ioctl_getwmeparam(vap, ireq);
break;
case IEEE80211_IOC_DTIM_PERIOD:
@ -1757,13 +1757,14 @@ ieee80211_ioctl_setwmeparam(struct ieee80211vap *vap, struct ieee80211req *ireq)
struct ieee80211com *ic = vap->iv_ic;
struct ieee80211_wme_state *wme = &ic->ic_wme;
struct wmeParams *wmep, *chanp;
int isbss, ac;
int isbss, ac, aggrmode;
if ((ic->ic_caps & IEEE80211_C_WME) == 0)
return EOPNOTSUPP;
isbss = (ireq->i_len & IEEE80211_WMEPARAM_BSS);
ac = (ireq->i_len & IEEE80211_WMEPARAM_VAL);
aggrmode = (wme->wme_flags & WME_F_AGGRMODE);
if (ac >= WME_NUM_AC)
ac = WME_AC_BE;
if (isbss) {
@ -1775,47 +1776,28 @@ ieee80211_ioctl_setwmeparam(struct ieee80211vap *vap, struct ieee80211req *ireq)
}
switch (ireq->i_type) {
case IEEE80211_IOC_WME_CWMIN: /* WME: CWmin */
if (isbss) {
wmep->wmep_logcwmin = ireq->i_val;
if ((wme->wme_flags & WME_F_AGGRMODE) == 0)
chanp->wmep_logcwmin = ireq->i_val;
} else {
wmep->wmep_logcwmin = chanp->wmep_logcwmin =
ireq->i_val;
}
wmep->wmep_logcwmin = ireq->i_val;
if (!isbss || !aggrmode)
chanp->wmep_logcwmin = ireq->i_val;
break;
case IEEE80211_IOC_WME_CWMAX: /* WME: CWmax */
if (isbss) {
wmep->wmep_logcwmax = ireq->i_val;
if ((wme->wme_flags & WME_F_AGGRMODE) == 0)
chanp->wmep_logcwmax = ireq->i_val;
} else {
wmep->wmep_logcwmax = chanp->wmep_logcwmax =
ireq->i_val;
}
wmep->wmep_logcwmax = ireq->i_val;
if (!isbss || !aggrmode)
chanp->wmep_logcwmax = ireq->i_val;
break;
case IEEE80211_IOC_WME_AIFS: /* WME: AIFS */
if (isbss) {
wmep->wmep_aifsn = ireq->i_val;
if ((wme->wme_flags & WME_F_AGGRMODE) == 0)
chanp->wmep_aifsn = ireq->i_val;
} else {
wmep->wmep_aifsn = chanp->wmep_aifsn = ireq->i_val;
}
wmep->wmep_aifsn = ireq->i_val;
if (!isbss || !aggrmode)
chanp->wmep_aifsn = ireq->i_val;
break;
case IEEE80211_IOC_WME_TXOPLIMIT: /* WME: txops limit */
if (isbss) {
wmep->wmep_txopLimit = ireq->i_val;
if ((wme->wme_flags & WME_F_AGGRMODE) == 0)
chanp->wmep_txopLimit = ireq->i_val;
} else {
wmep->wmep_txopLimit = chanp->wmep_txopLimit =
ireq->i_val;
}
wmep->wmep_txopLimit = ireq->i_val;
if (!isbss || !aggrmode)
chanp->wmep_txopLimit = ireq->i_val;
break;
case IEEE80211_IOC_WME_ACM: /* WME: ACM (bss only) */
wmep->wmep_acm = ireq->i_val;
if ((wme->wme_flags & WME_F_AGGRMODE) == 0)
if (!aggrmode)
chanp->wmep_acm = ireq->i_val;
break;
case IEEE80211_IOC_WME_ACKPOLICY: /* WME: ACK policy (!bss only)*/
@ -2945,7 +2927,7 @@ ieee80211_ioctl_set80211(struct ieee80211vap *vap, u_long cmd, struct ieee80211r
case IEEE80211_IOC_WME_AIFS: /* WME: AIFS */
case IEEE80211_IOC_WME_TXOPLIMIT: /* WME: txops limit */
case IEEE80211_IOC_WME_ACM: /* WME: ACM (bss only) */
case IEEE80211_IOC_WME_ACKPOLICY: /* WME: ACK policy (bss only) */
case IEEE80211_IOC_WME_ACKPOLICY: /* WME: ACK policy (!bss only) */
error = ieee80211_ioctl_setwmeparam(vap, ireq);
break;
case IEEE80211_IOC_DTIM_PERIOD:

View File

@ -2860,9 +2860,10 @@ ieee80211_tx_mgt_cb(struct ieee80211_node *ni, void *arg, int status)
static void
ieee80211_beacon_construct(struct mbuf *m, uint8_t *frm,
struct ieee80211_beacon_offsets *bo, struct ieee80211_node *ni)
struct ieee80211_node *ni)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct ieee80211com *ic = ni->ni_ic;
struct ieee80211_rateset *rs = &ni->ni_rates;
uint16_t capinfo;
@ -3021,8 +3022,7 @@ ieee80211_beacon_construct(struct mbuf *m, uint8_t *frm,
* Allocate a beacon frame and fillin the appropriate bits.
*/
struct mbuf *
ieee80211_beacon_alloc(struct ieee80211_node *ni,
struct ieee80211_beacon_offsets *bo)
ieee80211_beacon_alloc(struct ieee80211_node *ni)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211com *ic = ni->ni_ic;
@ -3104,7 +3104,7 @@ ieee80211_beacon_alloc(struct ieee80211_node *ni,
vap->iv_stats.is_tx_nobuf++;
return NULL;
}
ieee80211_beacon_construct(m, frm, bo, ni);
ieee80211_beacon_construct(m, frm, ni);
M_PREPEND(m, sizeof(struct ieee80211_frame), M_NOWAIT);
KASSERT(m != NULL, ("no space for 802.11 header?"));
@ -3125,10 +3125,10 @@ ieee80211_beacon_alloc(struct ieee80211_node *ni,
* Update the dynamic parts of a beacon frame based on the current state.
*/
int
ieee80211_beacon_update(struct ieee80211_node *ni,
struct ieee80211_beacon_offsets *bo, struct mbuf *m, int mcast)
ieee80211_beacon_update(struct ieee80211_node *ni, struct mbuf *m, int mcast)
{
struct ieee80211vap *vap = ni->ni_vap;
struct ieee80211_beacon_offsets *bo = &vap->iv_bcn_off;
struct ieee80211com *ic = ni->ni_ic;
int len_changed = 0;
uint16_t capinfo;
@ -3158,7 +3158,7 @@ ieee80211_beacon_update(struct ieee80211_node *ni,
* clear IEEE80211_BEACON_CSA.
*/
ieee80211_beacon_construct(m,
mtod(m, uint8_t*) + sizeof(struct ieee80211_frame), bo, ni);
mtod(m, uint8_t*) + sizeof(struct ieee80211_frame), ni);
/* XXX do WME aggressive mode processing? */
IEEE80211_UNLOCK(ic);

View File

@ -346,8 +346,7 @@ struct ieee80211_beacon_offsets {
uint8_t *bo_meshconf; /* start of MESHCONF element */
uint8_t *bo_spare[3];
};
struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *,
struct ieee80211_beacon_offsets *);
struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *);
/*
* Beacon frame updates are signaled through calls to iv_update_beacon
@ -375,7 +374,7 @@ enum {
IEEE80211_BEACON_MESHCONF = 11, /* Mesh Configuration */
};
int ieee80211_beacon_update(struct ieee80211_node *,
struct ieee80211_beacon_offsets *, struct mbuf *, int mcast);
struct mbuf *, int mcast);
void ieee80211_csa_startswitch(struct ieee80211com *,
struct ieee80211_channel *, int mode, int count);

View File

@ -461,8 +461,7 @@ struct ieee80211vap {
int (*iv_key_delete)(struct ieee80211vap *,
const struct ieee80211_key *);
int (*iv_key_set)(struct ieee80211vap *,
const struct ieee80211_key *,
const uint8_t mac[IEEE80211_ADDR_LEN]);
const struct ieee80211_key *);
void (*iv_key_update_begin)(struct ieee80211vap *);
void (*iv_key_update_end)(struct ieee80211vap *);

View File

@ -134,6 +134,7 @@ static int regen_tmpaddr(struct in6_ifaddr *);
static void nd6_free(struct llentry *, int);
static void nd6_free_redirect(const struct llentry *);
static void nd6_llinfo_timer(void *);
static void nd6_llinfo_settimer_locked(struct llentry *, long);
static void clear_llinfo_pqueue(struct llentry *);
static void nd6_rtrequest(int, struct rtentry *, struct rt_addrinfo *);
static int nd6_resolve_slow(struct ifnet *, struct mbuf *,
@ -483,7 +484,7 @@ skip1:
/*
* ND6 timer routine to handle ND6 entries
*/
void
static void
nd6_llinfo_settimer_locked(struct llentry *ln, long tick)
{
int canceled;
@ -512,12 +513,13 @@ nd6_llinfo_settimer_locked(struct llentry *ln, long tick)
}
/*
* Gets source address of the first packet in hold queue
* and stores it in @src.
* Returns pointer to @src (if hold queue is not empty) or NULL.
*
*/
static struct in6_addr *
* Gets source address of the first packet in hold queue
* and stores it in @src.
* Returns pointer to @src (if hold queue is not empty) or NULL.
*
* Set noinline to be dtrace-friendly
*/
static __noinline struct in6_addr *
nd6_llinfo_get_holdsrc(struct llentry *ln, struct in6_addr *src)
{
struct ip6_hdr hdr;
@ -530,7 +532,7 @@ nd6_llinfo_get_holdsrc(struct llentry *ln, struct in6_addr *src)
* assume every packet in la_hold has the same IP header
*/
m = ln->la_hold;
if (sizeof(hdr) < m->m_len)
if (sizeof(hdr) > m->m_len)
return (NULL);
m_copydata(m, 0, sizeof(hdr), (caddr_t)&hdr);
@ -541,8 +543,10 @@ nd6_llinfo_get_holdsrc(struct llentry *ln, struct in6_addr *src)
/*
* Switch @lle state to new state optionally arming timers.
*
* Set noinline to be dtrace-friendly
*/
void
__noinline void
nd6_llinfo_setstate(struct llentry *lle, int newstate)
{
struct ifnet *ifp;
@ -576,17 +580,12 @@ nd6_llinfo_setstate(struct llentry *lle, int newstate)
lle->ln_state = newstate;
}
void
nd6_llinfo_settimer(struct llentry *ln, long tick)
{
LLE_WLOCK(ln);
nd6_llinfo_settimer_locked(ln, tick);
LLE_WUNLOCK(ln);
}
static void
/*
* Timer-dependent part of nd state machine.
*
* Set noinline to be dtrace-friendly
*/
static __noinline void
nd6_llinfo_timer(void *arg)
{
struct llentry *ln;
@ -810,7 +809,30 @@ nd6_timer(void *arg)
goto addrloop;
}
}
} else if ((ia6->ia6_flags & IN6_IFF_TENTATIVE) != 0) {
/*
* Schedule DAD for a tentative address. This happens
* if the interface was down or not running
* when the address was configured.
*/
int delay;
delay = arc4random() %
(MAX_RTR_SOLICITATION_DELAY * hz);
nd6_dad_start((struct ifaddr *)ia6, delay);
} else {
/*
* Check status of the interface. If it is down,
* mark the address as tentative for future DAD.
*/
if ((ia6->ia_ifp->if_flags & IFF_UP) == 0 ||
(ia6->ia_ifp->if_drv_flags & IFF_DRV_RUNNING)
== 0 ||
(ND_IFINFO(ia6->ia_ifp)->flags &
ND6_IFF_IFDISABLED) != 0) {
ia6->ia6_flags &= ~IN6_IFF_DUPLICATED;
ia6->ia6_flags |= IN6_IFF_TENTATIVE;
}
/*
* A new RA might have made a deprecated address
* preferred.
@ -1156,8 +1178,10 @@ nd6_is_addr_neighbor(const struct sockaddr_in6 *addr, struct ifnet *ifp)
* Since the function would cause significant changes in the kernel, DO NOT
* make it global, unless you have a strong reason for the change, and are sure
* that the change is safe.
*
* Set noinline to be dtrace-friendly
*/
static void
static __noinline void
nd6_free(struct llentry *ln, int gc)
{
struct nd_defrouter *dr;
@ -1452,7 +1476,8 @@ nd6_ioctl(u_long cmd, caddr_t data, struct ifnet *ifp)
/* Mark all IPv6 address as tentative. */
ND_IFINFO(ifp)->flags |= ND6_IFF_IFDISABLED;
if ((ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0) {
if (V_ip6_dad_count > 0 &&
(ND_IFINFO(ifp)->flags & ND6_IFF_NO_DAD) == 0) {
IF_ADDR_RLOCK(ifp);
TAILQ_FOREACH(ifa, &ifp->if_addrhead,
ifa_link) {
@ -1725,9 +1750,12 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
lltable_link_entry(LLTABLE6(ifp), ln);
IF_AFDATA_WUNLOCK(ifp);
if (ln_tmp == NULL) {
/* No existing lle, mark as new entry */
/* No existing lle, mark as new entry (6,7) */
is_newentry = 1;
nd6_llinfo_setstate(ln, ND6_LLINFO_STALE);
if (lladdr != NULL) /* (7) */
EVENTHANDLER_INVOKE(lle_event, ln,
LLENTRY_RESOLVED);
} else {
lltable_free_entry(LLTABLE6(ifp), ln);
ln = ln_tmp;
@ -1764,10 +1792,9 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
*/
do_update = 0;
if (!is_newentry && llchange != 0)
if (is_newentry == 0 && llchange != 0) {
do_update = 1; /* (3,5) */
if (lladdr) { /* (3-5) and (7) */
/*
* Record source link-layer address
* XXX is it dependent to ifp->if_type?
@ -1778,10 +1805,8 @@ nd6_cache_lladdr(struct ifnet *ifp, struct in6_addr *from, char *lladdr,
EVENTHANDLER_INVOKE(lle_event, ln, LLENTRY_RESOLVED);
if (do_update) {
if (ln->la_hold != NULL)
nd6_grab_holdchain(ln, &chain, &sin6);
}
if (ln->la_hold != NULL)
nd6_grab_holdchain(ln, &chain, &sin6);
}
/* Calculates new router status */
@ -2011,8 +2036,10 @@ nd6_resolve(struct ifnet *ifp, int is_gw, struct mbuf *m,
* Heavy version.
* Function assume that destination LLE does not exist,
* is invalid or stale, so LLE_EXCLUSIVE lock needs to be acquired.
*
* Set noinline to be dtrace-friendly
*/
static int
static __noinline int
nd6_resolve_slow(struct ifnet *ifp, struct mbuf *m,
const struct sockaddr_in6 *dst, u_char *desten, uint32_t *pflags)
{

View File

@ -408,8 +408,6 @@ struct llentry *nd6_lookup(const struct in6_addr *, int, struct ifnet *);
struct llentry *nd6_alloc(const struct in6_addr *, int, struct ifnet *);
void nd6_setmtu(struct ifnet *);
void nd6_llinfo_setstate(struct llentry *lle, int newstate);
void nd6_llinfo_settimer(struct llentry *, long);
void nd6_llinfo_settimer_locked(struct llentry *, long);
void nd6_timer(void *);
void nd6_purge(struct ifnet *);
int nd6_resolve(struct ifnet *, int, struct mbuf *,

View File

@ -85,11 +85,11 @@ static struct dadq *nd6_dad_find(struct ifaddr *, struct nd_opt_nonce *);
static void nd6_dad_add(struct dadq *dp);
static void nd6_dad_del(struct dadq *dp);
static void nd6_dad_rele(struct dadq *);
static void nd6_dad_starttimer(struct dadq *, int);
static void nd6_dad_starttimer(struct dadq *, int, int);
static void nd6_dad_stoptimer(struct dadq *);
static void nd6_dad_timer(struct dadq *);
static void nd6_dad_duplicated(struct ifaddr *, struct dadq *);
static void nd6_dad_ns_output(struct dadq *, struct ifaddr *);
static void nd6_dad_ns_output(struct dadq *);
static void nd6_dad_ns_input(struct ifaddr *, struct nd_opt_nonce *);
static void nd6_dad_na_input(struct ifaddr *);
static void nd6_na_output_fib(struct ifnet *, const struct in6_addr *,
@ -1199,9 +1199,11 @@ nd6_dad_find(struct ifaddr *ifa, struct nd_opt_nonce *n)
}
static void
nd6_dad_starttimer(struct dadq *dp, int ticks)
nd6_dad_starttimer(struct dadq *dp, int ticks, int send_ns)
{
if (send_ns != 0)
nd6_dad_ns_output(dp);
callout_reset(&dp->dad_timer_ch, ticks,
(void (*)(void *))nd6_dad_timer, (void *)dp);
}
@ -1240,6 +1242,7 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
struct dadq *dp;
char ip6buf[INET6_ADDRSTRLEN];
int send_ns;
/*
* If we don't need DAD, don't do it.
@ -1276,8 +1279,10 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
return;
}
if ((dp = nd6_dad_find(ifa, NULL)) != NULL) {
/* DAD already in progress */
nd6_dad_rele(dp);
/*
* DAD already in progress. Let the existing entry
* to finish it.
*/
return;
}
@ -1310,13 +1315,12 @@ nd6_dad_start(struct ifaddr *ifa, int delay)
dp->dad_ns_lcount = dp->dad_loopbackprobe = 0;
refcount_init(&dp->dad_refcnt, 1);
nd6_dad_add(dp);
send_ns = 0;
if (delay == 0) {
nd6_dad_ns_output(dp, ifa);
nd6_dad_starttimer(dp,
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
} else {
nd6_dad_starttimer(dp, delay);
send_ns = 1;
delay = (long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000;
}
nd6_dad_starttimer(dp, delay, send_ns);
}
/*
@ -1386,7 +1390,8 @@ nd6_dad_timer(struct dadq *dp)
if ((dp->dad_ns_tcount > V_dad_maxtry) &&
(((ifp->if_flags & IFF_UP) == 0) ||
((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0))) {
nd6log((LOG_INFO, "%s: could not run DAD, driver problem?\n",
nd6log((LOG_INFO, "%s: could not run DAD "
"because the interface was down or not running.\n",
if_name(ifa->ifa_ifp)));
goto err;
}
@ -1396,9 +1401,8 @@ nd6_dad_timer(struct dadq *dp)
/*
* We have more NS to go. Send NS packet for DAD.
*/
nd6_dad_ns_output(dp, ifa);
nd6_dad_starttimer(dp,
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000, 1);
goto done;
} else {
/*
@ -1426,11 +1430,11 @@ nd6_dad_timer(struct dadq *dp)
* Send an NS immediately and increase dad_count by
* V_nd6_mmaxtries - 1.
*/
nd6_dad_ns_output(dp, ifa);
dp->dad_count =
dp->dad_ns_ocount + V_nd6_mmaxtries - 1;
nd6_dad_starttimer(dp,
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000);
(long)ND_IFINFO(ifa->ifa_ifp)->retrans * hz / 1000,
1);
goto done;
} else {
/*
@ -1517,10 +1521,10 @@ nd6_dad_duplicated(struct ifaddr *ifa, struct dadq *dp)
}
static void
nd6_dad_ns_output(struct dadq *dp, struct ifaddr *ifa)
nd6_dad_ns_output(struct dadq *dp)
{
struct in6_ifaddr *ia = (struct in6_ifaddr *)ifa;
struct ifnet *ifp = ifa->ifa_ifp;
struct in6_ifaddr *ia = (struct in6_ifaddr *)dp->dad_ifa;
struct ifnet *ifp = dp->dad_ifa->ifa_ifp;
int i;
dp->dad_ns_tcount++;

View File

@ -1531,7 +1531,7 @@ check_ipfw_rule_body(ipfw_insn *cmd, int cmd_len, struct rule_check_info *ci)
case O_IP_SRC_MASK:
case O_IP_DST_MASK:
/* only odd command lengths */
if ( !(cmdlen & 1) || cmdlen > 31)
if ((cmdlen & 1) == 0)
goto bad_size;
break;

View File

@ -149,6 +149,8 @@ static int sysctl_vm_page_blacklist(SYSCTL_HANDLER_ARGS);
SYSCTL_PROC(_vm, OID_AUTO, page_blacklist, CTLTYPE_STRING | CTLFLAG_RD |
CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_page_blacklist, "A", "Blacklist pages");
/* Is the page daemon waiting for free pages? */
static int vm_pageout_pages_needed;
static uma_zone_t fakepg_zone;

View File

@ -157,7 +157,6 @@ SYSINIT(vmdaemon, SI_SUB_KTHREAD_VM, SI_ORDER_FIRST, kproc_start, &vm_kp);
int vm_pages_needed; /* Event on which pageout daemon sleeps */
int vm_pageout_deficit; /* Estimated number of pages deficit */
int vm_pageout_pages_needed; /* flag saying that the pageout daemon needs pages */
int vm_pageout_wakeup_thresh;
#if !defined(NO_SWAPPING)

View File

@ -73,7 +73,6 @@
extern int vm_page_max_wired;
extern int vm_pages_needed; /* should be some "event" structure */
extern int vm_pageout_pages_needed;
extern int vm_pageout_deficit;
extern int vm_pageout_page_count;

View File

@ -43,8 +43,10 @@ BSARGS= DESTDIR= \
legacy: .MAKE .META
mkdir -p ${LEGACY_TOOLS}
${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${BTOOLSDIR} > $@2
${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${LEGACY_TOOLS} > $@
${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${BTOOLSDIR} \
> $@.distrib-dirs_btoolsdir
${MAKE} -C ${SRCTOP}/etc distrib-dirs DESTDIR=${LEGACY_TOOLS} \
> $@.distrib-dirs_legacy_tools
${BSENV} ${MAKE} -C ${SRCTOP} -f Makefile.inc1 ${BSARGS} $@
touch $@

View File

@ -8,7 +8,9 @@ all:
# we don't need to see it.
stage-distrib-dirs: .META
mkdir -p ${STAGE_OBJTOP}
${.MAKE} -C ${SRCTOP}/etc distrib-dirs -DWITH_TESTS DESTDIR=${STAGE_OBJTOP} > $@
${.MAKE} -C ${SRCTOP}/etc distrib-dirs -DWITH_TESTS \
DESTDIR=${STAGE_OBJTOP} > $@.distrib_dirs
touch $@
.include <bsd.prog.mk>

View File

@ -3,20 +3,18 @@
# This file is not autogenerated - take care!
DIRDEPS = \
games/bcd \
games/caesar \
games/factor \
games/fortune/fortune \
games/fortune/strfile \
games/fortune/datfiles \
games/fortune/unstr \
games/grdc \
games/morse \
games/number \
games/pom \
games/ppt \
games/primes \
games/random \
usr.bin/caesar \
usr.bin/factor \
usr.bin/fortune/fortune \
usr.bin/fortune/strfile \
usr.bin/fortune/datfiles \
usr.bin/fortune/unstr \
usr.bin/grdc \
usr.bin/morse \
usr.bin/number \
usr.bin/pom \
usr.bin/primes \
usr.bin/random \
.include <dirdeps.mk>

View File

@ -230,6 +230,18 @@ SUBDIR+= finger
SUBDIR+= ftp
.endif
.if ${MK_GAMES} != "no"
SUBDIR+= caesar
SUBDIR+= factor
SUBDIR+= fortune
SUBDIR+= grdc
SUBDIR+= morse
SUBDIR+= number
SUBDIR+= pom
SUBDIR+= primes
SUBDIR+= random
.endif
.if ${MK_GPL_DTC} != "yes"
SUBDIR+= dtc
.endif
@ -254,10 +266,8 @@ SUBDIR+= iscsictl
.if ${MK_KDUMP} != "no"
SUBDIR+= kdump
.if ${MACHINE_ARCH} != "aarch64" # ARM64TODO truss does not build
SUBDIR+= truss
.endif
.endif
.if ${MK_KERBEROS_SUPPORT} != "no"
SUBDIR+= compile_et

Some files were not shown because too many files have changed in this diff Show More