summaryrefslogtreecommitdiff
path: root/.zsh/zshrc/80_xtermtitle
blob: cbd7d0241ac735f20ea84304fc66893317887bc4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# zshrc/80_xtermtitle
#
# Fancy setting of the xterm title
#
# Based on the grml zshrc. Also see http://zshwiki.org/home/examples/hardstatus
#
# Copyright © 2011 Tobias Klauser
# Released under the terms of the Artistic Licence 2.0
#
# Source repository: git://git.distanz.ch/dotfiles/zsh.git
#

__ESC_print () {
  __info_print $'\ek' $'\e\\' "$@"
}

__set_title () {
  __info_print  $'\e]0;' $'\a' "$@"
}

__info_print () {
  local esc_begin esc_end
  esc_begin="$1"
  esc_end="$2"
  shift 2
  printf '%s' ${esc_begin}
  for item in "$@" ; do
    printf '%s ' "$item"
  done
  printf '%s' "${esc_end}"
}

_set_plain_xterm_title() {
  if [[ $TERM == screen* ]] ; then
    if [[ -n ${vcs_info_msg_1_} ]] ; then
      __ESC_print ${vcs_info_msg_1_}
    else
      __ESC_print "zsh"
    fi
  fi

  # adjust title of xterm
  # see http://www.faqs.org/docs/Linux-mini/Xterm-Title.html
  case $TERM in
    (xterm*|rxvt*)
      __set_title ${(%):-"%n@%m: %~"}
      ;;
  esac
}
precmd_functions+=_set_plain_xterm_title

_set_cmd_xterm_title () {
  # set hostname if not running on localhost
  if [[ -n "$HOSTNAME" ]] && [[ "$HOSTNAME" != $(hostname) ]] ; then
    NAME="@$HOSTNAME"
  fi

  # get the name of the program currently running and hostname of local machine
  # set screen window title if running in a screen
  if [[ "$TERM" == screen* ]] ; then
    # local CMD=${1[(wr)^(*=*|sudo|ssh|-*)]}       # don't use hostname
    local CMD="${1[(wr)^(*=*|sudo|ssh|-*)]}$NAME" # use hostname
    __ESC_print ${CMD}
  fi
  # adjust title of xterm
  case $TERM in
    (xterm*|rxvt*)
      __set_title "${(%):-"%n@%m:"}" "$1"
      ;;
  esac
}
preexec_functions+=_set_cmd_xterm_title

# vim:ft=zsh
ird action for both RTN_{LOCAL,BROADCAST} routes and RTN_UNICAST routes not pointing to the switch ports. However, packets that merely need to be forwarded by the switch are likely not control packets and can be therefore scheduled towards the CPU using a lower traffic class. Achieve the above by assigning the third action only to local and broadcast routes and have any other route use either of the first two actions, based on whether the route is gatewayed or not. This will also allow us to refresh routes using the local action and have them trap packets when their RIF is no longer valid following a NH_DEL event. One side effect of this patch is that we no longer give special treatment to multipath routes using both switch and non-switch ports towards their nexthops. If at least one of the nexthops can be resolved, then the device will forward the packets instead of trapping them. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Determine offload status using generic functionIdo Schimmel1-1/+1 The previous patch introduced a generic function to determine whether a route should be offloaded or not. Make use of it here. In the future we're going to add more conditions to this test (e.g., whether TOS is non-zero), so it makes sense to centralize it instead of open coding it in a few places. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: More accurately set offload flagIdo Schimmel1-20/+80 We currently set the RTNH_F_OFFLOAD flag for all routes using remote action, but this isn't always correct. If none of the nexthops associated with a gatewayed route can be offloaded into the device, then any packet hitting it would be trapped to the CPU and forwarded by the kernel. Solve this by pushing the setting of the offload flag to after the route was programmed into the device, thereby allowing us to take all the parameters into account. This change will also help us further in the patchset, when we refresh routes following the reception of NH_{ADD,DEL} events. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Refactor nexthop init routineIdo Schimmel1-31/+49 The nexthop init and de-init functions both have symmetric parts concerned with the reflection of the neighbour entry into the device's adjacency table, in case it's used by a gatewayed route. These sections of code also need to be called when a nexthop is marked as valid / invalid following NH_{ADD,DEL} events. Break these out into appropriate functions, so that they could be invoked following the reception of above events. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Remove FIB info from FIB entry structIdo Schimmel1-3/+1 After the previous changes, the FIB info is embedded in every nexthop group struct, which in turn is embedded in every FIB entry struct. We can therefore safely remove the FIB info from the entry struct. This has the added advantage of making the router-related structs more generic and suitable for use with IPv6 offloads. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Store routes in a more generic wayIdo Schimmel1-13/+27 Up until now, the only FIB entries that were associated with a nexthop group were routes to remote networks where all the nexthop devices had a valid router interface (RIF). This is in contrast to the FIB code, where all the routes are associated with a FIB info. The same design choice needs to be applied to the driver's cache. Based on the NH_{ADD,DEL} events which will be added later in the patchset, we need to be able to change the action (forward / trap) associated with all the routes using the nexthop group. However, if we can't link between the nexthop and the routes using it, then the above is impossible. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Add gateway indication to nexthop groupIdo Schimmel1-1/+8 The next patch is going to generalize the way in which we store routes. Instead of attaching a nexthop group only to gatewayed routes, one will be attached to each route, in a similar way to the way the FIB code stores its routes. The above means that any function operating on a nexthop group cannot assume the group represents only gatewayed nexthops. One such function is the one that refreshes a nexthop group and updates the adjacency table following nexthop changes. For a nexthop group that doesn't represent any gateways this function would essentially be a NOP, but it would be useful if it did update the action associated with any route using it. This will allow us to later consolidate code paths when a nexthop changes following NH_{ADD,DEL} events. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Use nexthop's scope to set action typeIdo Schimmel1-1/+1 We currently use the scope of the FIB info to distinguish between a direct unicast route and a gatewayed one. However, the kernel is perfectly happy to configure a route with scope UNIVERSE to a directly connected network. Instead, we can rely on the first nexthop's scope to check if the route is gatewayed or not. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Store nexthops in a hash tableIdo Schimmel2-4/+55 Later in the patchset we'll add the NH_{ADD,DEL} events which will let us know when a nexthop is considered to be dead. Based on these events we need to be able to add or remove the nexthop from the device's tables. Therefore, store the private nexthop structs in a hash table and use the kernel's fib_nh struct as the key, so that we'll be able to easily find them when the events are received. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Store nexthop groups in a hash tableIdo Schimmel2-52/+54 Currently, when we're notified about a new RTN_UNICAST route we perform a lookup on the nexthop group list looking for a group with a matching configuration to that found in the FIB info. This is quite inefficient. Instead, we can simply rely on the kernel to consolidate several FIB configurations into the same FIB info and use the FIB info as the key for our private nexthop group struct. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: spectrum_router: Nullify nexthop's neigh pointerIdo Schimmel1-2/+3 When we invalidate a nexthop we should also invalidate its neighbour entry pointer as it might be destroyed later on. This makes the nexthop de-init function symmetric with its init and also ensures nobody will try to access the neighbour entry. Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> 2017-02-08mlxsw: acl: Fix mlxsw_afa_block_commit error pathJiri Pirko