To rebuild a port and ports which this port depends on:
portmaster -DRf origin/port
portupgrade -Rf origin/port
To rebuild a port and ports which depends on it:
portmaster -Drf origin/port
portupgrade -rf origin/port
To list packages with their dependencies
pkg query -g "%n:%dn" '*'
Then use script to rebuild required – example for openssl
sh
REBUILD=$(pkg query -g "%n:%dn" '*' | grep openssl | cut -d : -f 1 | sort -u)
portmaster -D $REBUILD