{"action":"created","issue":{"url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/12","labels_url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/12/comments","events_url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/12/events","html_url":"https://github.com/tohojo/sqm-scripts/issues/12","id":103785453,"number":12,"title":"ifb associated with interface IFACE is still empty","user":{"login":"braveheartleo","id":4935251,"avatar_url":"https://avatars.githubusercontent.com/u/4935251?v=3","gravatar_id":"","url":"https://api.github.com/users/braveheartleo","html_url":"https://github.com/braveheartleo","followers_url":"https://api.github.com/users/braveheartleo/followers","following_url":"https://api.github.com/users/braveheartleo/following{/other_user}","gists_url":"https://api.github.com/users/braveheartleo/gists{/gist_id}","starred_url":"https://api.github.com/users/braveheartleo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/braveheartleo/subscriptions","organizations_url":"https://api.github.com/users/braveheartleo/orgs","repos_url":"https://api.github.com/users/braveheartleo/repos","events_url":"https://api.github.com/users/braveheartleo/events{/privacy}","received_events_url":"https://api.github.com/users/braveheartleo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":31,"created_at":"2015-08-28T19:57:27Z","updated_at":"2015-09-02T21:26:34Z","closed_at":null,"body":"In `sqm-scripts - 1.0.2-1`, the function `get_ifb_associated_with_if()` in `/usr/lib/sqm/functions.sh` does not properly match the associated ifb.\r\n\r\nBefore the fix:\r\n```\r\n~# /etc/init.d/sqm stop\r\nSQM: /usr/lib/sqm/stop-sqm: Stopping eth0.2\r\nSQM: ifb associated with interface eth0.2: \r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth0.2 shaper deleted\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth0.2 interface deleted\r\nSQM: /usr/lib/sqm/stop-sqm: Stopping eth1\r\nSQM: ifb associated with interface eth1: \r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth1 shaper deleted\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth1 interface deleted\r\n```\r\n\r\nThe fix is simple:\r\n```\r\n--- functions.sh.orig\t2015-08-29 03:31:10.000000000 -0800\r\n+++ functions.sh\t2015-08-29 03:31:27.000000000 -0800\r\n@@ -65,7 +65,7 @@\r\n get_ifb_associated_with_if() {\r\n     CUR_IF=$1\r\n     # CUR_IFB=$( tc -p filter show parent ffff: dev ${CUR_IF} | grep -o -e ifb'[[:digit:]]\\+' )\r\n-    CUR_IFB=$( tc -p filter show parent ffff: dev ${CUR_IF} | grep -o -e ifb'[^)]\\+' )    # my editor's syntax coloration is limitied so I need a single quote in this line (between eiditor and s)\r\n+    CUR_IFB=$( tc -p filter show parent ffff: dev ${CUR_IF} | grep -o -e ifb'[^)]*' )    # my editor's syntax coloration is limitied so I need a single quote in this line (between eiditor and s)\r\n     sqm_logger \"ifb associated with interface ${CUR_IF}: ${CUR_IFB}\"\r\n     echo ${CUR_IFB}\r\n }\r\n```\r\n\r\nThe `+` attempts to match the preceeding token ONE OR MORE times. The problem here is that the preceeding token evaluates to a zero match (empty) because we are using the negated character class `[^)]`. While this may be the case, it is \"important to remember that a negated character class still must match a character.\" [1] In other words, the negated character class must still match a character (`)` in this case), but the resulting token evaluates to zero (empty). Sounds a bit confusing, no? ;) The appropriate repetition to use here, given the preceeding token, is the `*`, which matches ZERO OR MORE times. [2]\r\n\r\nAfter the fix:\r\n```\r\n~# /etc/init.d/sqm stop\r\nSQM: /usr/lib/sqm/stop-sqm: Stopping eth0.2\r\nSQM: ifb associated with interface eth0.2: ifb4eth0.2\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth0.2 shaper deleted\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth0.2 interface deleted\r\nSQM: /usr/lib/sqm/stop-sqm: Stopping eth1\r\nSQM: ifb associated with interface eth1: ifb4eth1\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth1 shaper deleted\r\nSQM: /usr/lib/sqm/stop-sqm: ifb4eth1 interface deleted\r\n```\r\n\r\nCheers,\r\nianp\r\n\r\n[1] http://www.regular-expressions.info/charclass.html#negated\r\n[2] http://www.regular-expressions.info/repeat.html"},"comment":{"url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/comments/137249266","html_url":"https://github.com/tohojo/sqm-scripts/issues/12#issuecomment-137249266","issue_url":"https://api.github.com/repos/tohojo/sqm-scripts/issues/12","id":137249266,"user":{"login":"tohojo","id":396657,"avatar_url":"https://avatars.githubusercontent.com/u/396657?v=3","gravatar_id":"","url":"https://api.github.com/users/tohojo","html_url":"https://github.com/tohojo","followers_url":"https://api.github.com/users/tohojo/followers","following_url":"https://api.github.com/users/tohojo/following{/other_user}","gists_url":"https://api.github.com/users/tohojo/gists{/gist_id}","starred_url":"https://api.github.com/users/tohojo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tohojo/subscriptions","organizations_url":"https://api.github.com/users/tohojo/orgs","repos_url":"https://api.github.com/users/tohojo/repos","events_url":"https://api.github.com/users/tohojo/events{/privacy}","received_events_url":"https://api.github.com/users/tohojo/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T21:26:34Z","updated_at":"2015-09-02T21:26:34Z","body":"Or you could go the other way and whitelist expected characters: `ifb[[:alnum:]_-]+` would be alpha-numeric characters and _ and -."}}